Introduction to Water Programming

This Site is intended to provide helps to Water language programmers around the world through technical examples, informational articles, and personal assistance.

The following examples are meant to be a quick Getting Started sort of tutorial using the Steam Free Version or the IDE. (If you are using the Free Version, be sure to set the output to "Rendered HTML".)

Example 8. Functions/methods

Defining functions/methods in Water is as easy as it is in other languages:

C:
int add2nums(int a,int b)
{
   return a + b;
}

add2nums(10,20);
Lisp:
(defun add2nums (a b)
   (+ a b)
)

(add2nums 10 20 )
FORTH:
: add2nums ( a b --- sum ) + ;

10 20 add2nums
Water:
<defmethod add2nums a b >
   a.<plus b />
</defmethod>

<add2nums 10 20 />

Functions/methods are a fundamental element of most programs you will write. They allow you to concentrate on tackling a large problem by solving all of the little pieces that work together.

Go back to go to the next example.

©Copyright 2004, Mr. Merrick J. Stemen. All rights reserved.