
A proof of concept for the J.T.W. preprocessor is the SUPERFOR macro,
which is an enhanced BASIC-style FUR loop.  Here is how to invoke the
SUPERFOR macro in your TT(*.jtw) file:

@example
BEGINMAIN
PD SUPERFOR (VAR int i = 0 TU 10)
PD BEGIN
PD PD System.out.println("i=" + i);
PD END
ENDMAIN
@end example

The above code results in the following printout:

@example
i=0
i=1
i=2
i=3
i=4
i=5
i=6
i=7
i=8
i=9
i=10
@end example

The STEP size argument is optional, here is an example with an
explicit STEP size announced:

@example
BEGINMAIN
PD SUPERFOR (VAR int i = 0 TU 10 STEP 2)
PD BEGIN
PD PD System.out.println("i=" + i);
PD END
ENDMAIN
@end example

The above code results in the following printout:

@example
i=0
i=2
i=4
i=6
i=8
i=10
@end example

NI()If the DOWNTU keyword is given instead of the TU keyword then the
loop will count downwards from the first given number to the second,
even if a postive STEP size is given.  Here is an example with a
negative STEP size:

@example
BEGINMAIN
PD SUPERFOR (VAR int i = 10 DOWNTU 0 STEP 2)
PD BEGIN
PD PD System.out.println("i=" + i);
PD END
ENDMAIN
@end example

The above code results in the following printout:

@example
i=10
i=8
i=6
i=4
i=2
i=0
@end example

Note that the specification of the SUPERFOR macro doesn't need
constants for the values of TT(start), TT(stop) and TT(step-size).
They can be any variable or more generally any Java expression, and
those expressions will be evaluated only once, should your code have
side effects, i.e. changes the value of a variable in your code.  See
the following example.  The expression TT(++y) has the side effect of
incrementing the value of TT(y) before returning the value of TT(y):

@example
BEGINMAIN
PD VAR int x = 20;
PD VAR int y = 15;
PD SUPERFOR (VAR int i = x TU (2 * ++y))
PD BEGIN
PD PD System.out.println("i=" + i);
PD END
ENDMAIN
@end example

The above code results in the following printout:

@example
i=20
i=21
i=22
i=23
i=24
i=25
i=26
i=27
i=28
i=29
i=30
i=31
i=32
@end example

@section Elisp source code for the superfor macro

The following code belongs in the file
TT(TILDE()/jtw/jtw-build-jtw.el) which in itself is too
large for inclusion in this manual.  You can find this code by
visiting @ref{J.T.W. tarball}.  Alternatively, you can study this
fragment of the file TT(~/jtw/jtw-build-jtw.el) which deals
with the SUPERFOR macro.  In the listing that follows,
TT(*pp-namespace*) stores a string containing a long arbitrary name to
prevent accidental aliasing of the INCLUDE directives with rest of the
comments code.

m4_include(superfor.el)

@section A bug in J.T.W. superfor

The question mark operator TT(a ? b : c) which expands to

@example
Type result;
IF (a) THEN
BEGIN
PD result = b;
END
ELSE
BEGIN
PD result = c;
END
@end example

where type can be any Java type is not directly supported by the
arguments to the SUPERFOR macro in J.T.W.  Elsewhere the question mark
is supported.  Instead in the SUPERFOR macro you have to write the
following code to get a question mark operator online:

m4_include(SuperFor.jtw.m4)

where the symbol QUIST compiles into a question mark: TT(?).  When
built, the program prints out the following:

@example
i=0
i=1
i=2
i=3
i=4
i=5
i=6
i=7
i=8
i=9
i=10
@end example

