THE INTERCAL PROGRAMMING LANGUAGE REFERENCE MANUAL Donald R. Woods & James M. Lyon Copyright Donald R. Woods & James M. Lyon 1973 INTERCAL 1. INTRODUCTION The names you are about to ignore are true. However, the story has been changed significantly. Any resemblance of the programming language portrayed here to other programming languages, living or dead, is purely coincidental. 1.1 ORIGIN AND PURPOSE The INTERCAL programming language was designed the morning of May 26, 1972 by Donald R. Woods and James M. Lyon, at Princeton University. Exactly when in the morning will become apparent in the course of this manual. It was inspired by one ambition; to have a compiler language which has nothing at all in common with any other major language. By 'major' was meant anything with which the authors were at all familiar, e.g., FORTRAN, BASIC, COBOL, ALGOL, SNOBOL, SPITBOL, FOCAL, SOLVE, TEACH, APL, LISP, and PL/I. For the most part, INTERCAL has remained true to this goal, sharing only the basic elements such as variables, arrays, and the ability to do I/O, and eschewing all conventional operations other than the assignment statement (FORTRAN "="). 1.2 ACRONYM The full name of the compiler is "Compiler Language With No Pronounceable Acronym", which is, for obvious reasons, abbreviated "INTERCAL". 1.3 ACKNOWLEDGMENTS The authors are deeply indebted to Eric M. Van and Daniel J. Warmenhoven, without whose unwitting assistance this manual would still have been possible. 2. FUNDAMENTAL CONCEPTS In this section an attempt is made to describe how and why INTERCAL may be used; i.e., what it is like and what it is good for. 2.1 SAMPLE PROGRAM Shown below is a relatively simple INTERCAL program which will read in 32-bit unsigned integers, treat them as signed, 2's-complement numbers, and print out their absolute values. The program exits if the absolute value is zero. Note in particular the inversion routine (statements 6 through 14), which could be greatly simplified if the subroutine library (see section 5) were used. A more detailed analysis of a program is made in section 6 of this manual. DO (5) NEXT (5) DO FORGET #1 PLEASE WRITE IN :1 DO .1 -0=/? .B, and #0 otherwise. The expression may be expanded as described above to instead set .C to #1 or #2. Note also in statement 220 the occurrence of ~"#65535c65535". Although these operations select the entire value, they are not extraneous, as they ensure that the forthcoming Vs will be operating on 32-bit values. In several virtual computed GO TOs the DO FORGET #1 (statement 15 in the earlier example) has been omitted, since the next transfer of control would be a DO RESUME #1. By making this a DO RESUME #2 instead, the FORGET may be forgotten. In statement 64, note that .2 is STASHed twice by a single statement. This is perfectly legal. Lastly, note in statements 243 and 214 respectively, expressions for shifting 16- and 32-bit variables logically one place to the left. Statement 231 demonstrates right-shifting for 32-bit variables. MIKE GETS TO INSERT THE PROGRAM HERE! 6.3 Program Listing 1 (1000) PLEASE IGNORE .4 2 PLEASE ABSTAIN FROM (1005) 3 (1009) DO STASH .1 + .2 + .5 + .6 4 DO .4 right angle | | ( wax precedes line label | | ) wane follows line label | | [ U turn | | ] U turn back | | { embrace | | } bracelet | | * splat flags invalid statements | | & ampersand[5] unary logical AND | | V V unary logical OR | | (or book) | | V- bookworm unary exclusive OR | | (or universal qualifier) | | $ big money unary exclusive OR (ASCII) | | | c| change binary mingle | | ~ sqiggle binary select | | _ flat worm | | overline indicates "times 1000" | | + intersection separates list items | | / slat | | \ backslat | | @ whirlpool | | -' hookworm | | ^ shark | | (or simply sharkfin) | | #I[] blotch | |_____________________________________________________________________| Table 2 (top view). INTERCAL character set. __________________________________ 5) Got any better ideas? NOTES ON THE ATARI IMPLEMENTATION The Atari implementation of INTERCAL differs from the original Princeton version primarily in the use of ASCII rather than EBCDIC. Since there is no "change" sign (c) in ASCII, we have substituted the "big money" ($) as the mingle operator. We feel that this correctly represents the increasing cost of software in relation to hardware. (Consider that in 1970 one could get RUNOFF for free, to run on a $20K machine, whereas today a not quite as powerful formatter costs $99 and runs on a $75 machine.) We also feel that there should be no defensible contention that INTERCAL has any sense. Also, since overpunches are difficult to read on the average VDT, the exclusive-or operator may be written ?. This correctly expresses the average person's reaction on first encountering exclusive-or, especially on a PDP-11. Note that in both of these cases, the over-punched symbol may also be used if one is masochistic, or concerned with portability to the Princeton compiler. The correct over-punch for "change" is "c/" and the correct over-punch for V is "V-". These codes will be properly printed if you have a proper printer, and the corresponding EBCDIC code will be produced by the /IBM option on the LIST command.