
When your classes become large and unwieldy, it becomes useful to
split a source file into several compilation units.  the most natural
division into compilation units is at the level of methods.  with each
method in a separate file you can manage methods that are excessively
large.  here is how to use file inclusion in the J.T.W. language.
first comes the TT(Foo.jtw) file with all bodies of methods harvested
from them:

m4_dnl m4_undefine([PD])
m4_dnl m4_define([PD],[@tie{}@tie{}@tie{}])

@example
CLASS Foo
BEGIN
PD INCLUDE "Foo-apple.method";
PD INCLUDE "Foo-banana.method";
PD INCLUDE "Foo-carrot.method";
END
@end example

Here are the files that get included.  the first file is
TT(Foo-apple.method):

@example
PROPERTY int prop1; COMM(/* declares a property for use with the apple method. */)

METHOD void apple(COMM(/* parameters */))
BEGIN
PD prop1 = prop1 + 1;
PD COMM(/* rest of body of apple method */)
END
@end example

the second file is TT(Foo-banana.method):

@example
METHOD void banana(COMM(/* parameters */))
BEGIN
PD COMM(/* body of banana method */)
END
@end example

the third file is TT(Foo-carrot.method):

@example
METHOD void carrot(COMM(/* parameters */))
BEGIN
PD COMM(/* body of carrot method */)
END
@end example

when all of the file inclusions have been carried out by the J.T.W.
to JAVA compiler, the code that JAVAC sees will be something like
this:

@example
COMM(/* Automatically generated file. Do not edit! */)
COMM(// #foomatic #location (Foo.jtw:1))
CLASS Foo
@{
PD COMM(// #foomatic #location (apple.method:1))
PD int prop1; COMM(/* declares a property for use with the apple method. */)
PD
PD void apple(COMM(/* parameters */))
PD @{
PD PD prop1 = prop1 + 1;
PD PD COMM(/* rest of body of apple method */)
PD @}
PD COMM(// #foomatic #location (banana.method:1))
PD void banana(COMM(/* parameters */))
PD @{
PD PD COMM(/* body of banana method */)
PD @}
PD COMM(// #foomatic #location (carrot.method:1))
PD void carrot(COMM(/* parameters */))
PD @{
PD PD COMM(/* body of carrot method */)
PD @}
PD COMM(// #foomatic #location (Foo.jtw:6))
@}
@end example

Note the use of the value TT(#foomatic) of the string
TT(*pp-namespace*) (where EM(pp) stands for pre-processor) that is a
long arbitrarily defined string to prevent accidental aliasing with
the rest of the commented code that the user of the system might
write.  m4_ignore(The variable TT(*list-namespace*) by default has the
value TT(#transalpine) so it is unlikely to clash with any comments
that a user of J.T.W. might write.)  The TT(#location) directives are
used to keep track of the original line number in the source file.
Using Emacs batch mode executing the Elisp code: TT(jtw-build-jtw.el),
error messages in TT(Foo.java) now point back to the original
TT(Foo.jtw) file, or one of the files that get TT(#include)d like so:
TT(apple.method), TT(banana.method) or TT(carrot.method).  If you are
particularly clever, you can reuse the same METHOD in different
classes.

Version 1.0 of J.T.W. used the EM(C Pre-Processor) (CPP) to manage the
TT(#location) directives but unfortunately CPP destroys comments in
the target file, and Java uses EM(/** DOTS */) comments to document
the program's behaviour so CPP cannot be used.

