HolonJ Forth
Using HolonJ
Clock
Tic Tac Toe

Classes
Methods
Parameter
Variables
Forth
Flow Control
Compiler
Libraries
Constructors
Exception

HolonJForth

Writing Java Programs in Forth

HolonJ builds Java programs with a Forth syntax. The Java definition

public static void main(string [] args) {
     System.out.println("Hello world!");
}

becomes

: main ( string [] args -- ) 
      ." Hello world!"  ;

It is possible to express much of Forth in Java. But there are limits. We are programming to the Java Virtual Machine (JVM), not to a Forth machine. 

What can be done

Most Forth kernel words, stack manipulation, arithmetic and logical operators, flow control structures are available in their standard Forth way. You can create new words, both low and high level. The Java program is written in postfix notation. 

What can't be done

Variable and Constant are replaced by the data types of Java (boolean, char, byte, int, long, float, double, string). 

Create..Does> are replaced by Java classes.

@ and ! are replaced by access operators that are valid for all data fields. 

No Quit (interpreter). HolonJ offers a different way to test words interactively. The output of HolonJ is a class file. The class file is loaded and linked dynamically in the JVM. HolonJ uses the umbilical principle to load classfiles into the JVM automatically. You can test Java methods interactively from HolonJ.

The Forth multi-tasker is replaced by Java threads.

What is done differently

The parameter stack is limited to the current word. The word has access to the parameters that have been declared in the stack signature. The word returns zero or one argument. 

The return stack also exists locally. It is used for temporary storage and for the implementation of do..loop. The return stack is not needed for the execution of Forth words because the execution is handled by the JVM. Advantage: an imbalanced return stack does not abort the program.

The language of HolonJ

The following pages describe the language used in HolonJ.

next