[net.micro.mac] Preliminary Review of TML's Pascal Compiler for the Mac

mss@dartvax.UUCP (Mark Sherman) (10/28/85)

Since the original posting of TML's address, I haven't seen any discussion
of their Pascal compiler for the Mac. Mine came and I spent about 6 hours
running it through some programs to see what would happen. It seems nice,
but I'm still not sure about widespread replacement of the Lisa.

For those who missed the first msg, I'll first give a brief description. "TML
Systems' MacLanguage Series Pascal Compiler" is supposed to be a Lisa Pascal
and MacPascal compatible compiler. I assume that means at the source level.
It is also supposed to be MDS compatible. I assume that means at the object
level. In fact, the main program disk looks like the MDS disk minus EXEC and
ASM and with PASCAL and FONT/DA Mover. It appears that Edit, Linker and RMaker
are the same as in MDS, with perhaps the exception that the transfer
menu also has a Pascal entry. When I included my Asm on the same disk, it
did not recognize Pascal in the transfer menu.

The two disk system cost $105. As I mentioned, the first disk contains the
runnable programs. The second disks contains the necessary include files,
linkable Rel files, and example applications (including a desk accesory).
You apparently need a 512K Macintosh with an external disk drive. I guess
the current system is a prerelease since it is numbered 0.9 and the cover
letter implies that they were willing to ship early so that people could see
the product rather than waiting for a final version. I recall comments like
that on the phone from the sales person as well (TML's wife).  Therefore,
keep in mind that all of my comments below refer to an early release running
on a 512K Mac w/ an external Sony drive.

My motivation for trying this product was to see if I could abandon my Lisa
for development. A primary reason for staying with the Lisa is the
Supplement that Apple provides, which in essence, guarantees me the ability
to use any features that Apple develops. I have programs that use Appletalk,
Graf3D, drivers and nearly everything else that Apple provides. Recently,
Apple has included MDS files as well in the supplement, so I was willing to
try an MDS compatible system. Since TML claimed to be MDS and Lisa
compatible, it seemed like a good bet. My results are inconclusive.

I tried three programs: a one-line "Hello world", Steve Maker's SKEL
program, and a program I wrote that uses my coroutine package to build binary
trees and then compare the trees' data by walking both trees in parallel.
The latter two programs had been developed and debugged on the Lisa
Workshop, and I believe them to work.

The one-line program compiled and ran just as one would expect. The window
provided by the Pascal runtime system for OUTPUT scrolls when it reaches the
end but does not save the scrolled text. The font height does not seem to be
a multiple of the window height, so one sees partial lines in the window.  I
added a simple Read of an integer, and typed in "abc". The program eats it
w/o complaint. However, I did not turn on the "checking" facilities, either
by the menu switch in the compiler or a compiler option in the source.

The SKEL program required some modifications to make it compile under TMS's
compiler. (I'll give a list of incompatibilities I found later.) The
resulting program was 8K; the Lisa generated version was 4K. I was quite
surprised at the difference, so I turned on the "produce assmbler code"
option on both the Lisa and TML. I did not find an explanation after reading
through a half a dozen routines. For the most part, the code was the same --
I'd give the Lisa a bit better rating since it placed some local pointer
variables into registers while TML fetched them each time from local
storage, but relatively few instructions were involved. (On the other hand,
I noticed that TML used word-long moves in loops to copy data structures
where Lisa used byte-moves -- in the cases I saw, the blocks were even-size
lengthed. I do not know what would happen if the blocks were odd-size
lengthed.) I would guess that RMaker on both machines would produce the same
size resources -- after all, the resource definitions are just another
assembly language. Thus I have no good explanation. Processing times are shown
below:

			Lisa	TML
Compile and Code Gen	 67	120
Link			 31	115
RMaker			 18	 30
Maccom			 11	 --

Total			130	285


All times are clock time in seconds.  The total time is not the sum of the
individuals -- it's the total clock time from when I started to when I was
finished. I used an Exec file on the Lisa -- Exec does not work for TML (I
tried). For TML, I tried to select as fast as I could (I typed ahead of the
SFGetFile dialog box to pick the correct files). Finally, note that the
Linker performs two different functions: on the Lisa, the linked file is
combined by RMkaer into the application; TML (in the typical case) runs
RMaker first to translate resources and then uses the Linker to build the
final application. By watching the MDS linker run, my gut reaction is that
it takes much longer to process the resource file than RMaker -- perhaps the
typical development cycle for TML should be use the linker first, RMaker
second (which can be done, but the documentation implies the order I used.)
Finally, again by watching the system run, 60 seconds of the TML Pascal
Compile time was spent reading the interface files for MemTypes, QuickDraw,
OSIntf, and ToolIntf -- probably the four files that you will always
include.  I suppose that is why the check-syntax option is provided -- so
you can fly through those files and get to your problems.

My third program uses my coroutine package which is a separate Pascal Unit
and a piece of assembly code. After editing, everything compiled and linked,
but did not run. (Bombs with ID=2 somewhere.) I did not get a chance to
track down why the program fails. I highly suspect the coroutine package
which does funny things with the stack, but I thought the only assumption I
made was that A5 had to point at globals -- I'm pretty careful about
restoring registers during stack switching. If I have the time, I'll try to
see what is going wrong.

If I get some large block of time in the future, I'll try using the system
on a Hyperdrive and on a MacXL. I expect that will improve the timings
considerably. If I get a chance, I wil post those timing to the net as well.

Despite claims of being Lisa compatible, I did have to edit my files to
compile them. Below is a brief list and my personal explanation -- which may
not be correct.

1) Units are missing.
2) SIZEOF is missing.
3) EXIT is missing.
4) May not dereference function results.
5) Forwarded functions may not repeat their return types.
6) Integer literals may not be directly coerced to pointers
7) Shortcut | and & operators are missing
8) Literal calculations are not permitted in CONST declarations.
9) String types are assignment incompatible.
10) Conditional compilation unavailable.
11) Procedures in the same segment must be contiguous.
12) Identifier lengths differ.

1) At the moment, Units aren't available. Attempting to use them causes the
compiler to bomb (usually ID=10). Thus separate compilation is also not around
(at least, not in an obvious way to me -- perhaps if I were to pick the
"generate desk accessory option...") The "include" files for the toolbox, et
al., are plain Pascal sources which are included, reparsed, and so on, each
time you compile. The way that I included my own units is that I commented
out "Unit", "Interface", "Implementation" and "END.", and placed a "Forward"
after all of the subprogram declarations in the interface. The documentation
implies that Units are in the way, and the fact that the compiler bombs
rather just spiting out lots of syntax errors tells me that some of the Unit
processing is already in place. I do not know when Units will appear.

2) SIZEOF is missing, but I am told by the system that it will added. I hope
so.

3) EXIT is missing and the system givces no indication that I'll get it back.
The example programs used GOTOs. So did I.

4) In Lisa Pascal, I can have a function "foo" return a pointer, and
immediately use the pointer, as in "foo(...)^". TML flags this as a syntax
error.

5) Forwarded functions may not repeat their return types. I believe the Lisa
manual argues that the Lisa compiler would also reject repeated return
types, but it doesn't. TML's does.

6) In Lisa Pascal, I can declare a pointer type "p" and coerce an integer
literal to it, e.g., p($908). In TML, I have to go through the generic
POINTER function, e.g., "p(POINTER($908))".

7) Lisa Pascal offers shortcut | (or) and & (and), which are useful for
expressions like "IF (x <> NIL) & (x^.foo <> 0) THEN ...". Instead, I added
some statements that conditionally build up the appropriate boolean value
since I cannot reaaly afford the NIL pointer being used in a reference.

8) Lisa Pascal allows me to compute values in CONSTs, e.g., 
"CONST pi = 3.14; r = 10; circum = 2*pi*r;" I cannot even write 
"TotalMemory = 24*1024;" in TML Pascal.

9) In Lisa Pascal, I can assign different length string variables among
themselves, e.g.,

TYPE str10 = string[10]; Str255 = string[255];
VAR a: str10; b:str255;
a := copy(b,1,10);

I get an assignment incompatibility with TML Pascal. Without the reference
manual (which TML promises to send when they finish it), I cannot really say
whether the problem is with the type declarations, the assignment, the
variables or what. It works on the Lisa, it doesn't on TML.

10) Conditional compilation unavailable: I didn't try this one, but the
partial documentation delivered with the compiler gives a list of compiler
switches in comments, and IFC, et al. are not there.

11) Procedures in the same segment must be contiguous. This could be a
tricky bug to catch -- the segment directive $S collects all of the
following procedures into a separate segment (until thenext $S); when the
compiler hits a $S, it will first delete any code for a previous segment by
that name and start fresh. Thus if you switch back and forth between
segments in Lisa Pascal, you will find only the last set of procedures in
each segment. I ditched all of my segmentation during the tests.

12) Lisa Pascal only uses the first 10 characters of identifiers; TML uses
more, as it found some of my identfiers that didn't match after the first 10
characters.  However, I do not know how many characters it checks.

Unfortunately for me, technical suport for TML is through Compuserve, MCI
and US Mail. Alas, I use Arpanet, Usenet, CSNet and the phone. They say they
want only written comments. Maybe if I get my act together, I'll print a
copy of this review and send it off (but us telecommuters find printers hard
to use.)

If starting a new project from scratch, this might not be a bad way to go,
especially with a hard disk and an MDS system. But one cannot just pluck the
Lisa stuff off the old 2-10 and drop it on the Mac.  When I get 1.0, I'll
run everything again to see what has changed.  I'd appreciate hearing from
others who tried this product.

		-Mark Sherman (mss@Darmouth.csnet)