This document describes major changes to Water since Nov 21, 2004
Water v5 has a considerable number of changes since Water v4.
The purpose of those changes were to make Water easier to learn,
easier to use, more flexible, faster running and have a broader
scope of applicability. Water v4 source code will not run in v5.
How to Convert Your Version 4 code to Version 5
- Save your old code in a safe place
- Bring a copy of your old code up in the editor
- Select it.
- Choose the right click menu, Convert Selection to / Water version 5.
This will make the most common easy changes but certainly not all.
Note that this is computationally expensive and will take a while.
On one fast laptop, converting a large (80K charcters) file took 20 seconds.
Run your new code and compare it to the old code.
It helps if you have calls to "test" in your old code that
you can run in version 5. Note that you can convert tests just like
you convert regular code. For difficult code sections it will hep to be able
to run the coe in version 4 and compare intermediate values.
Major New Features
Math
- All new trigonometry methods. See the right click menu, Math/trigonometry
- New statistics methods: See the right click menu, Math/statistics
- Simplified random and new right click menu "Math/random"
- Changed Water's floating point number from single precision to double precisionfor greater accuracy in engineering applications.
Rich UI
- ui.lines lets you draw points, lines, and polygons
Can change line thickness, colors, translation, rotation and scaling.
Useful for 2D graphics including animation.
- Dialog boxes including:
- a general purpose one that allows arbitrary other
rich ui components as content and a "multiple choice" button set.
See ui.show_dialog
- a "yes/No" one that returns true or false: See ui.show_boolean_dialog
- One that gets a string from the user: see ui.show_input_dialog
- one that lets you choose file(s) and/or folder(s).
see ui.show_file_dialog
for_each
- Powerful generalization of the old "returns" parameter.
It now is called "combiner" and takes a method as an argument
that lets you combine the result of each iteration in
an infinite variety of ways such as collect a vector, join
strings or add up numbers for a total.
- Takes a number as a subject, and loops that number of times.
Defmethod and Defclass
Major new facility for making it easier to
pass in arguments in a variety of formats.
respelling of names and change of _subject. See below for details
ekind.bytes
A new execution kind that makes it possible to put any string
in an XML tag without special quoting, even if it has unmatched
angle brackets or other wierd characters.
Formatters:
Provides different levels of printed representations
of objects.
Operating System Interface
new "os" class lets you execute a string as if in a "shell" or "dos prompt" on the os,
returns the 'printed out' string as the value.
new "ping" method for testing internet connectivity.
Java calling Water Interface
A new Java class named 'Water" makes it much easier to call Water from Java.
Water User Folder
For Windows OS, the default location of the water_user_folder has been
C:\Documents and Settings\user-name\water_user_folder.
The Windows US makes it hard to get to this diretory.
The new default loacation is
C:\Documents and Settings\user-name\My Documents\water_user_folder.
which is much easier to get to via "My Documents".
If you have your water_user_folder inthe lold location, it will still work,
but you get a warning message in the console saing that it will be
easier to work with if you simply move the folder to the new location.
ROOT OBJECT
The new root object is called "wob" for water object.
There still is a 'thing' class for making random objects,
It is a subclass of wob. wob is "tight" and doesn't allow
making instances with random additional fields, but thing still does.
Inheritance of fields has been made more uniform throughout.
If you inherit from wob, you won't automatically be allowed to
add _other_unkeyed and _other_keyed fields when creating an instance,
but inherited from thing or anything that supports _other_unekeyd and _other_keyed
will let you add those fields.
VECTOR
v is now a shortcut for vector as in to make a vector of items.
SVG
Scalable Vector Graphics tags have been define.
See Right click menu, SVG submenu for examples.
Documentation:
Expanded table of contents and new index.
Contracts are shown in a table as well as in CXS.
Expanded Quick Reference Guide.
The "doc" class now has a body that takes calls to test in it.
These are formatted for presentation as an example when the doc
is formatted but they can also be used as test cases.
You can use the Test menu to run such files through the test runner.
New example files.
Error Messages
More accurate selection of the source code where an error occurred.
Improved error messages, some of which tell you when you've typed in
something that looks like java or C what the equivalent Water is.
IDE
Selecting expressions by double-clicking on the end of a tag.
Upper right result pane tells you what source code created the result.
new right click insert menus for:
Documentation Creation
Math (trigonometry, random, advanced)
Misc/java
Vector
Performance:
General code speed up about 2.5 times
Formatting HTML sped up more than 10 times.
Testing
test now takes a 'language' parameter whose value defaults to "water"
but can also be "java" to facilitate testing your Java code.
More test cases. Accessible from the doc.
Plus a whole bunch of minor improvements all over the place!
__________________
Incompatibilities
Most of the syntax and semantics of the language remain the same.
Some major changes were required to simplify things while increasing
functionality.
There is a new 'deprecation' facility that often will give error messages
that tell you what has changed and how to update your code.
But this doesn't work perfectly for everything, and besides
its good to know what you're in for in converting old code.
Below are the most common things you'll likely run in to.
Version 4 == Version 5
CLASSES
- thing == wob (for the root object, still use thing as the class for a misc. data object.)
- example == test (in the documentation, just use the 'test' method for embedding examples.)
- float == double
- random_number == random
- web == resource
- ==
- boat. ==
METHODS
- attributes == fields (for creating "attribute fields" of a call inside the content of a call.
- concat == join see join doc for additional join functionality
- init == make
- parent_make == next_method
- start == htm_class (in a web app for the default method name of a class)
- ==
- boat. ==
All uses of "expr" have been changed to "expression". All of these except wobl.expr
are unlikely to have been used by most users.
- wob.expr == expression
- expr_var == expression_var
- expr_call == expression_call
- also paramter method_expr == method_expression
- expr_path == expression_path
- expr_to_xml == expression_to_xml
- execute_expr == execute_exprression
- expr_to_name == expression_to_name
- expr_to_full_name == expression_to_full_name
- expr_to_cxs == expression_to_cxs
- method.format_state.special_expr == param name change to special_expression
- method.to_cxs3.special_expr == param name change to special_expression
- expr_format_utils == expression_format_utils
- expr_to_xml_for_char == expression_to_xml_for_char
- expr_to_uri_fields == expression_to_uri_fields
- also renamed one of its params, a_expr == a_expression
- make_expr_path == make_expression_path
PARAMETERS
- == (anonymous methods must now be given a name of null.)
- method and class calls, the params must have a default value, so change
method foo x to method foo x=req
- required == req
- optional == opt
- rest == _other_unkeyed
- other_args == _other_keyed
- execution_kind == ekind
- ek_code == ekind.code
- ek_data == ekind.xdata
- ek_hypertext == ekind.mixed
- ek_string == ekind.string
- force_ek_code == force_ekind_code
FIELDS
_new_object == _subject (in a 'make' method),
_new_class == _subject (at top level within a call to class)
SYNTAX
\n ==
(now using the XML escape character convention instead of C-language convention)
DO
'do' no longer takes attributes
do-repeat now uses for_each.
counter
Becomes:
5. value
FOR_EACH
instead of: primes. value
use something like:
primes.
value. skip
else value
Lots of new features in for_each. Please read the documentation on it.
LAST
now 0 (instead of 1) refers to the last element in the vector.
DEFMETHOD & DEFCLASS
Methods and classes are now more similar. If they define _other_unkeyed,
must now all have the same ekind for _other_unkeyed.
If that ekind is something other than ekind.code (the default) then
it must be defined before the first call, in the order that the source code is
loaded. Sometimes its inconvenient to do so, so there is a new method named
declare_other_unkeyed_ekind which lets you declare the ekind of a call before
the method of the call is defined. This helps the parser do the right thing.
When defining a parameter in a call to method or class, the
type (if any) must be in the 3rd position and the ekind (if any) must be in the 4th position.
Before these two were interchangeable. the new 5th position is the "name" used
only for _other_unkeyed.
When calling methods or classes that have both optional parameters and _other_unkeyed,
all unkeyed args will go to the _other_unkeyed parameter. Thus any
optional args must be passed via key.
Example:
y >
y >
"defclass" is now spelled "class"
"defmethod" is now spelled "method".
This is shorter, doesn't leave you wondering what the "def" means,
and, in the case of "method", since we are making an instance of method
and "method" is the name of a class, it makes more sense than defmethod.
"class" is still a method, just like defclass was.
Now neither take subjects. If you want to stick a method in a class, use
to make a method named "launch" in the class "boat".
You can still do