CAL (programming language)
CAL (Conversational Algebraic Language) was a programming language and system designed and developed by Butler Lampson at Berkeley in 1967. CAL is a version of the seminal [[JOSS] language with a number of cleanups and new features to take advantage of the SDS 940.
The Berkeley SDS was used for the development of the Tymshare commercial time-sharing platform, and CAL was offered as a programming environment to its customers. CAL saw "almost no use" in this market, but had a lasting impact by influencing the development of Tymshare SUPER BASIC which copied a number of its features. Those features, in turn, appeared in BASIC-PLUS on the PDP-11, which is the direct ancestor of Microsoft BASIC.[1]
Description
Basic concepts
JOSS had been designed to be used by non-programmers in the US Air Force, and to aid with that, Rand Corporation designed custom computer terminals that were easier to set up and use. These terminals also included a custom character set that implemented common mathematical symbols like ≥
and ≠
.
To a large degree, CAL was a version of JOSS that replaced these sorts of customizations with more common solutions like >=
and #
.[2] The other noticeable difference was that CAL was all upper-case and did not require a period at the end of the line.[3] The commands were otherwise almost identical and the overall structure and syntax the same, porting from JOSS to CAL is simple.
As with JOSS, CAL had an interactive user interface that allowed the user to type in statements in "direct mode" or programs to be run in "indirect mode". In BASIC the former is more commonly referred to as "immediate mode". Both used a two-part line number, known as the part and step. Parts were generally used to group related statements into subroutines. In CAL, the part number could be between 0 and 999, and the step from 0 to 999999.[4]
There were two versions of CAL, released in 1967 and 1969. The following description will be based primarily on the later version, unless otherwise noted.
Statements
As in JOSS, CAL supported the TO
command to branch to a provided part or step, as in TO PART 3
or TO STEP 4.5
, and DO
for subroutine calls, as in DO PART 9
to perform the entire part, or DO STEP 5.1
to run that single step and then return. The later syntax was useful when there were many small subroutines as they could be implemented on a single line without an associated RETURN
or similar concept.[5]
One of the more notable stylistic features of JOSS was the concept of "statement modifiers" which controlled the operation of other statements. In most languages, one would write something to the effect of "if this expression is true, then do this...". In JOSS, this order was reversed, and such statements took the form Type "HELLO" if X=5.
. CAL added some syntactic sugar to this basic concept by adding the new modifier UNLESS
, which, depending on context, led to more obvious code, TYPE "IT IS NOT EQUAL TO FIVE" UNLESS X=5
.[6]
CAL further modified the basic if statement by adding THEN
and ELSE
. In JOSS, if one wanted to assign the value 5 to a variable A if the value of B was larger than 10, and 0 otherwise, the code would be:
Set A=5 if B>10. Set A=0 if B<=10.
This sort of either/or assignment is very common, and CAL improved on JOSS by implementing an Elvis operator:[7]
A=IF B>10 THEN 5 ELSE 0
A similar modification was the WHERE
statement, used to set variables as part of an if or for. It was similar in concept to the if/then/else structure, but could have any number of items. For instance,{{{1}}}
.
Looping in JOSS was also controlled by a modifier, the For
. This used somewhat confusing syntax, Type i for i=1(2)10.
runs a loop from 1 to 10 stepping by 2, so it would print 1,3,5,7,9. CAL cleaned this up with the BY
and TO
keywords, so the equivalent code in CAL would be TYPE I FOR I=1 BY 2 TO 10
. As in JOSS, the range of the for could be defined using BY and TO, an explicit list of numbers, FOR I=2,5,7
, or a mixture of both, {{{1}}}
. CAL further modified the for loop by adding conditional exits, using WHILE
and UNTIL
. For instance, TYPE A FOR A=1 BY 1 WHILE A<=50
or TYPE B FOR B=1 UNTIL A=50
. In the later case, the BY is assumed to be 1.[8]
A much more minor change, in the 1969 version, was the elimination of the SET
command for variable assignment. This had been optional in direct mode in JOSS but required in program statements, and the 1967 version of CAL followed this rule.[9] The 1969 version made it optional in both cases.
References
Citations
- ^ Lampson, "Systems", Research, Microsoft.
- ^ Manual 1969, p. 7.
- ^ Manual 1969, p. 23.
- ^ Manual 1969, p. 8.
- ^ Manual 1969, p. 15.
- ^ Manual 1969, p. 12.
- ^ Manual 1969, p. 14.
- ^ Manual 1969, p. 13.
- ^ Manual 1967, p. 3.
Bibliography
- Lampson, Butler (June 1969). CAL Reference Manual for SDS 940 Time-Sharing Computer System (PDF). Scientific Data Systems.
- Lampson, Butler (June 1967). CAL Reference Manual for SDS 940 Time-Sharing Computer Systems (PDF). Scientific Data Systems.
External links
- Lampson, Butler W (1967), CAL reference manual (PDF), University of California, Berkeley.
- CAL (PDF), Tymshare Manuals, Reference Series, Bit savers, June 1969. (Tutorial and reference)