Java is a strongly typed language and you have to indicate the type of every argument in a function call. 

: main  ( string [] args -- )  ... ;

The method main expects an array args of string arguments. This syntax is similar to the Java language, but the return result is included in the stack notation in the usual Forth manner.

: printnumber  ( int number -- ) ...
: timestring   ( -- string ) ...     

A result has no name, only a type. The word (method) is the result name.

No universal argument stack

Java has local stack frames. When a method is called, the parameters are implemented as local variables in the stack frame of the called method. Thus the method only has access to the arguments that are transferred in the call. The arguments are accessed by the names that are defined in the parameter list.

: square  ( int x -- int )    x x *  ;

Only one return value

The method can deliver one or zero results. 


In practice these properties are useful and not restrictive. Some Forth words do have more than one return value, e.g. rot . However, HolonJ implements the stack manipulation words as macros, which insert Java byte code inline. We don't have a function call here and thus there is no restriction. 

If a Java method returns multiple values, it packs the data into an object. You can do the same in HolonJ. Let's say we return the coordinates of the central point of a drawing. 
- Forth      : center   ( -- x  y )  ... ;
- HolonJ    : center   ( -- point )  ... ;  where point is an object of class Point.




1998-2013 Wolf Wejgaard