Classic Computer Magazine Archive COMPUTE! ISSUE 19 / DECEMBER 1981 / PAGE 172

COMAL: Another Language?

Jim Butterfield
Toronto, Canada

There are a lot of "languages" around for small computers. Only two are in common use: BASIC (most often by Microsoft) and Machine Language.

Most of the others classify as in-between languages: not as friendly as BASIC, not as fast as machine language. Each have their advocates (fanatics?) who extol the advantages which a specific language can bring to a specific application. But BASIC and machine language look like they will reign supreme for quite a while yet. Until local computer shops bristle with book titles such as "101 FORTH Games," "Some Common SMALL-TALK Programs," and "Hands-On SNOBOL For The PET/CBM," many users will prefer to stay in the mainstream of the home computing community and learn one or two simple languages well.

Now we have COMAL to add to the computer Tower of Babel. Another language, another chance to sidetrack? COMAL does have its interesting features, especially to those raised on BASIC. Let's take a look.


COMAL is public domain. In other words, it's free; and you can help yourself to a friend's copy with a clear conscience. In Canada, Commodore has distributed copies to all dealers; you can get one by asking your dealer to make you a copy of the disk and documentation. In the USA, the COMAL Users Group, 5501 Groveland Terrace, Madison WI 53716, will send you the disk for a charge of $12.95; or for $47.50 you get a kit including disks, documentation, binder, and a newsletter subscription; in either case, add $2.00 for shipping/handling.

You get what you pay for, right? Not in this case: COMAL is a massive system (it will fit only into a 32K system with disk) and has features that make it well worth considering, particularly for educational use.

COMAL came into existence in Denmark. It was first defined by Borge R. Christensen and Benedict Leofstedt in 1974. At that time it was a form of extended BASIC. It has been expanded and refined into the current version, COMAL-80, by Mogens Kjaer.


COMAL still retains much of the flavor of BASIC, and for that reason it's a very easy language for BASIC users to pick up. The first impression that a user gets is rather intriguing: it seems as if you may type in your program in BASIC — and when you say LIST, it comes back in a PASCAL-like language!

How can this happen? Most BASIC users learn that their program is "tokenized" as it is input. The individual letters of PRINT get scrunched together and stored as a single byte called a token; that's why you can type in a line such as 100 ? A and list it back as 100 PRINT A. COMAL tokenizes your input to a remarkable extent, so that a line input as 5 FOR J = 1 TO 8 will list back as 5 FOR J: = 1 TO 8 DO. Note that a colon has crept in after the J, and that the word DO has been added.

So: with a few new rules, you may just type in a program in its BASIC form, and COMAL will adapt it into its own internal format. Some of the new rules are easy: for example, be sure to put a space after each keyword (don't say FORK, say FOR K). Others take a little more practice: subroutines are now called Procedures and, instead of GOSUB-ing to them, you EXEC-ute them. And you don't use line numbers for GOTO and GOSUB, you use names (or "Labels"). But these are not difficult. It's easy for a BASIC person to jump into COMAL.

…And More

But it's more than just a reworded BASIC system. There are a whole new series of capabilities.

Some are easy to understand and on most people's wish-lists. You may now use variables HORSESHOE and HOUSEFLY without confusion (in BASIC, only the first two letters are meaningful). IF has been beefed up to include ELSE and other features, allowing you to code IF M = 12 THEN M = 1; Y = Y + 1 ELSE M = M + 1 ENDIF. Note that we are using a semicolon instead of a colon to separate statements, and we terminate the IF sequence with an ENDIF. This isn't just needless bookkeeping: ENDIF allows us to set the range of the IF statement to part of a line or multiple lines.

Other COMAL features are recognizable as structured language extensions. The user will find CASE (replacing ON A GOTO…), WHILE, and REPEAT .. UNTIL. Procedures can be used as subroutines or as function definitions; and you may pass parameters to or from procedures. Strings require a little more care than in BASIC, but string handling is more powerful after you get used to it.

COMAL is fast. You'll see no loss of speed from BASIC.


The language is nice, but it's new. You may have to wait a while before you find a community of other COMAL users around you. The BASIC language feature I miss most is the SYS command—at least I haven't found it yet. I like to be able to extend some programs with machine language inserts if necessary. Some 4.0 disk commands don't appear to be supported by COMAL; I haven't found a way to initiate a SCRATCH or COLLECT from the language. There doesn't seem to be a built-in exit to BASIC cold start, which would be a way around the previous problem.

COMAL for the PET/CBM comes in two forms; the smallest takes up 16K of memory. This may cramp the size of programs. COMAL does pack programs in memory more efficiently, but you have less space to work with from the start.

COMAL seems ideal for educational environments, particularly for those who like to teach structured programming techniques.

It's a helpful language in many ways: as easy as BASIC and very like it. It has goodies that BASIC can't match. The structure and balance of COMAL lead me to suspect that there will be a compiler along one of these days.

And the price is right.