perm filename WEE[NET,GUE] blob
sn#016394 filedate 1972-12-20 generic text, type T, neo UTF8
00100 ↑↑
00200 .spacing 1
00300 ####
00400 .BREAK
00500 .skip 5
00600 .center
00700 ECL PROGRAMMER'S MANUAL[*]
00800 .skip 2
00900 .center
01000 by
01100 .skip 2
01200 .center
01300 Ben Wegbreit
01400 .center
01500 Ben Brosgol
01600 .center
01700 Glenn Holloway
01800 .center
01900 Charles Prenner
02000 .center
02100 Jay Spitzen
02200 .skip 5
02300 .center
02400 21-72
02500 .skip 5
02600 .center
02700 CENTER FOR RESEARCH IN COMPUTING TECHNOLOGY
02800 .center
02900 Harvard University
03000 .center
03100 Cambridge, Massachusetts
03200 .center
03300 September 1972
03400 .skip 10
03500 .FIGURE 4
03600 [*] This work was supported in part by the U. S. Air Force
03700 Electronic Systems Division under Contract F19628-71-C-0173
03800 and by the Advanced Research Projects Agency under Contract
03900 F19628-71-C-0174.
04000 .break
04100 .nonumber
04200 .page
04300 ↑&PREFACE\&
04400 .paragraph
04500 The ECL programming system is based on the programming
04600 language EL1 which is the work of Ben Wegbreit and is
04700 described in his doctoral dissertation ∀Studies in
04800 Extensible Languages∩, Harvard University, June 1970.
04900 .paragraph
05000 This manual was written by Glenn Holloway, Ben Brosgol,
05100 Pat Griffiths, and Ben Wegbreit.
05200 .paragraph
05300 The parsing algorithm is a modification of F.#DeRemer's
05400 method. The parser production system was written by
05500 Pat Griffiths, Charles Prenner and Judy Townley.
05600 .paragraph
05700 The interpreter was written by Ben Wegbreit.
05800 .paragraph
05900 The storage management routines and garbage collector
06000 were written by Glenn Holloway and Charles Prenner.
06100 .paragraph
06200 The compiler for data type definitions was written
06300 by Ben Brosgol.
06400 .paragraph
06500 The facility for control of data type
06600 behavior was implemented by William Conrad, who has rewritten
06700 and improved substantial portions of the system.
06800 .paragraph
06900 The utility routines described in sections 5 and 6 were written
07000 by Mark Davis, Glenn Holloway, and Ben Wegbreit.
07100 .paragraph
07200 The multi-task control facility is the work of Charles
07300 Prenner and is described in his doctoral dissertation
07400 ∀Multi-path Control Structures for Programming
07500 Languages∩, Harvard University, June 1972.
07600 .paragraph
07700 The compiler for procedures is the work of Glenn Holloway
07800 and is described in his doctoral dissertation (forthcoming).
07900 .paragraph
08000 The non-deterministic control facility is the work
08100 of Jay Spitzen and is described as part of his doctoral
08200 dissertation (forthcoming) and in ↑&Proceedings ACM 72\&.
08300
08400 .paragraph
08500 Numerous individuals have made suggestions about the
08600 design and implementation of this system. These
08700 include Daniel Bobrow, Thomas Cheatham, Jr.,
08800 Robert Kierr, and Richard Stallman. Their assistance is gratefully
08900 acknowledged.
09000 .break
09100 .skip 2
09200 .indent 35
09300 September 1972
09400 .break
09500 .number 0
09600 .page
09700 1.##↑&INTRODUCTION\&
09800 .skip 2
09900 .title 1.1##AN OVERVIEW OF THE ECL PROGRAMMING SYSTEM
10000 1.1##AN OVERVIEW OF THE ECL PROGRAMMING SYSTEM
10100 .paragraph
10200 The ECL programming system has been designed
10300 as a tool for tackling 'difficult' programming projects--projects
10400 on which existing languages could
10500 be used only with considerable waste in machine
10600 or programmer time.
10700 .paragraph
10800 Such projects include much of the frontier of computer
10900 technology; they are found whenever several application areas are conjoined
11000 and whenever solution of a problem requires linguistic
11100 development--in algorithmic notation or information structures.
11200 Examples range from the management of large scale distributed
11300 data bases to applied artificial intelligence.
11400 .paragraph
11500 Specifically, projects of this nature are systems characterized
11600 by two requirements:
11700 .skip 1
11800 .left margin 10
11900 .indent -5
12000 (1)##Considerable experimentation is required to develop the
12100 system; that is, the design and development of the system must go hand
12200 in hand. Typically, this occurs when problems are so
12300 complex that significant computer assistance and experimentation
12400 are needed in system design.
12500 .skip 1
12600 .indent -5
12700 (2)##When a complete system is ultimately designed and programmed,
12800 it must be possible to take the working programs and produce
12900 a highly efficient product--both in machine time and
13000 space--without changing the basic algorithms or their representation.
13100 .left margin 0
13200 .paragraph
13300 The ECL system has been designed as a vehicle for such undertakings.
13400 At the present time an experimental version of the system is
13500 operational--a version which only partially meets the above
13600 requirements. Additional system development is under
13700 way and will continue for some time. This section outlines
13800 the ↑&goals\& of this work and the ECL system as planned.
13900 Thus this section should be read as a prospectus. The remainder of this
14000 manual, however, describes the existing system--as of the last
14100 manual revision. Periodic revisions will be issued as new features are
14200 added.
14300 .paragraph
14400 The ECL programming system consists of a programming
14500 language, called EL1, and a system built around that language
14600 to provide a complete environment for the human-oriented
14700 use of the language. The system allows on-line conversational
14800 construction, testing, and running of programs.
14900 It includes an interpreter, a fully compatible compiler,
15000 and an editor--all callable at run-time, on programs
15100 constructible at run-time either by the programmer or as the
15200 result of computation.
15300 .paragraph
15400 EL1 is an extensible language. Thus it
15500 provides a number of facilities for defining extensions
15600 so that the programmer can readily shape
15700 the language to the problem at hand, and progressively
15800 reshape the language as his understanding of the problem
15900 and its solution improves. Like the familiar notions of subroutine
16000 and macro definition, these extension facilties allow one
16100 to abstract significant aspects of a complex algorithm.
16200 Such functional abstraction serves both as a representational aid and
16300 as a handle on the production of an efficient product.
16400 .left margin 0
16500 .paragraph
16600 Specifically, the language provides facilities for
16700 extension on four axes: syntax, data types, operations,
16800 and control.
16900 .skip 1
17000 .left margin 10
17100 .indent -5
17200 (1)##Syntactic extension allows the specification of new
17300 linguistic forms and their meaning in terms of existing
17400 forms.
17500 .skip 1
17600 .indent -5
17700 (2)##Data type extension allows the programmer to define
17800 new data types and new information structures whenever
17900 needed to model the problem at hand.
18000 EL1 is significant in that considerable
18100 attention has been given to the efficient representation of
18200 programmer-defined data types. There is a special compiler
18300 for data-type definitions which computes space-efficient
18400 packing of structures into machine words, and generates
18500 machine code for rapid handling of objects and their components.
18600 .skip 1
18700 .indent -5
18800 (3)##Operator extension allows the programmer to define new
18900 operations on new data types and to extend existing operations
19000 to cover new types. There are two key points here:
19100 .skip 1
19200 .left margin 15
19300 .indent -5
19400 (a)##Operators and procedures are not restricted
19500 to act on built-in types in the language but can, and in
19600 general will, take arguments whose mode is programmer-defined.
19700 .page
19800 .skip 1
19900 .indent -5
20000 (b)##Declarations can be made to allow the compiler to
20100 perform type-checking and type-conversion
20200 code generation. Hence, it is possible to write programs
20300 operating on extended data types whose execution is
20400 as efficient as that of programs using only built-in modes.
20500 .skip 1
20600 .left margin 10
20700 .indent -5
20800 (4)##Control extension allows the creation, deletion, and
20900 coordination of independent asynchronous processes,
21000 called ∀paths∩ in ECL. The extension mechanisms
21100 are sufficiently flexible that co-routines, the P and V
21200 operations of Dijkstra, multiple parallel returns, and path
21300 scheduling are all definable in the system as proper
21400 extensions. Hence, it is straightforward to program
21500 almost all known control structures as well as an unknown
21600 variety of others.
21700 .left margin 0
21800 .paragraph
21900 In addition to these definition mechanisms provided by the
22000 language, the ECL programming system provides a number of
22100 other handles which the programmer can use to extend and
22200 tailor the environment in which he operates. Many of the
22300 system's facilities are written in the language and hence
22400 are open to modification by the
22500 programmer. These include the compiler, one of the editors,
22600 and most of the input/output and file system.
22700 .paragraph
22800 Extensibility alone is, however, not
22900 sufficient. Its counterpart--contractibility--is also required.
23000 Once running prototype programs have been produced, it must be
23100 possible to subject them to a sequence of ↑&contractions\&--commitments
23200 to subsequent nonvariation--to
23300 obtain a final system optimal for the project requirements.
23400 .paragraph
23500 The ECL programming system and the EL1 programming
23600 language have been designed to allow this.
23700 Programs can be run
23800 either by an interpreter or by a fully compatible compiler.
23900 Compiled and interpreted functions can call each other
24000 in either direction.
24100 Compilation can itself be progressively refined.
24200 The programmer is free to supply as much declarative
24300 information as he wishes (or knows) at a given time and the
24400 compiler will do the best it can with the information given.
24500 Successive recompilation with additional information will
24600 produce progressively better code.
24700 .test page 12
24800 .paragraph
24900 In summary, the intended application of the ECL
25000 programming system is the programming project which would
25100 otherwise be prohibitively expensive. To this end, the
25200 ECL system has been designed to allow flexible
25300 programmer-oriented program construction and testing
25400 as well as facilities for subsequent optimizing
25500 contractions to produce an efficient final
25600 product.
25700 .skip 1
25800 .title
25900 1.2##PURPOSE OF THIS MANUAL
26000 .paragraph
26100 This manual is an introductory reference. It provides
26200 little or no motivation for the material it presents. It
26300 is not organized so as to lead the reader gently into
26400 ECL as a true primer would.
26500 Rather, it assumes that the reader, though perhaps ignorant of
26600 ECL, has some familiarity with programming languages and
26700 programming systems.
26800 .paragraph
26900 Section 2 describes the EL1 language in some detail, independent of the
27000 ECL system. It is an introduction in the
27100 sense that it proceeds from simple to more complicated notions, and usually
27200 defines terms before they are used. However, it is primarily organized to permit quick reference and easy comparison of EL1 with
27300 other languages.
27400 .paragraph
27500 Section 3 describes the interactive use of ECL. It
27600 assumes an understanding of section 2 as well as the
27700 ability to cope with TECO, the PDP-10 text editor.
27800 .paragraph
27900 Section 4 briefly describes each built-in routine
28000 of the system.
28100 .paragraph
28200 Section 5 describes a number of EL1 procedures, mostly utility
28300 packages of general applicability.
28400 .paragraph
28500 Section 6 describes a package of routines for making
28600 measurements on programs and functions.
28700 .paragraph
28800 This copy is a draft of the manual. It is incomplete.
28900 Sections which are planned but not yet written are
29000 indicated in the text by a section number and a title in
29100 square brackets. Your corrections of and suggestions
29200 about this draft will be appreciated.
29300 .skip 3
29400 .break
29500 ↑↑
29600 .title
29700 .page
29800 .spacing 1
29900 2.##↑&INTRODUCTION TO EL1\&
30000 .skip 2
30100 .title 2.1##FORMS
30200 2.1##FORMS
30300 .paragraph
30400 EL1 programs are composed of basic units called
30500 .index form
30600 ∀forms∩.
30700 Examples of EL1 forms which have counterparts in
30800 most other programming languages are:
30900 .left margin 10
31000 .skip 1
31100 .indent -5
31200 (1)##constants such as 13 and TRUE,
31300 .indent -5
31400 .skip 1
31500 (2)##variables such as##x##and##pressure,
31600 .indent -5
31700 .skip 1
31800 (3)##expressions composed of infix and prefix operations
31900 such as ##x+y,##i-j*k, and ##-q1/q2,
32000 .indent -5
32100 .skip 1
32200 (4)##selections of components of compound objects such as
32300 b[i]## and ##position[3*x],
32400 .indent -5
32500 .skip 1
32600 (5)##procedure calls like f(x) and foo(i,j+k,a[n]).
32700 .skip 1
32800 .left margin 0
32900 A form in EL1 is a syntactically complete unit, and each form represents
33000 a value.
33100 Forms may be combined according to the composition
33200 rules of the language to obtain larger forms.
33300 The remainder of this section describes
33400 EL1 by describing the individual forms which make up the language: how they are
33500 written and how they will be evaluated.
33600 .test page 10
33700 .skip 3
33800 .index constant
33900 .title 2.2##CONSTANTS AND THE BASIC DATA TYPES
34000 2.2##CONSTANTS AND THE BASIC DATA TYPES
34100 .paragraph
34200 Although the number of data types in EL1 is virtually
34300 unlimited, all are based on a relatively small number
34400 of primitive types, including:
34500 .left margin 10
34600 .skip 1
34700 .indent -5
34800 (1)##Booleans: logical truth values;
34900 .indent -5
35000 .skip 1
35100 (2)##numbers:##integers and reals;
35200 .indent -5
35300 .skip 1
35400 (3)##characters;
35500 .indent -5
35600 .skip 1
35700 (4)##labels: values used for controlling program flow;
35800 .indent -5
35900 .skip 1
36000 .index reference
36100 (5)##references: pointers to data objects;
36200 .indent-5
36300 .skip 1
36400 (6)##the empty value.
36500 .left margin 0
36600 .paragraph
36700 A few other data types, although not
36800 technically primitive, are basic to the implementation
36900 and are also built-in. These include:
37000 .skip 2
37100 .left margin 10
37200 .indent -5
37300 .index mode
37400 .index data type
37500 (7)##modes: values which describe data types
37600 (in this manual, "mode" and "data type" are synonymous);
37700 .indent -5
37800 .skip 1
37900 .index SYMBOL
38000 (8)##symbols: which permit efficient representation of symbolic expressions
38100 (e.g. programs);
38200 .indent -5
38300 .skip 1
38400 .index STRING
38500 (9)##strings: arrays of characters;
38600 .skip 1
38700 .indent -6
38800 .index procedure
38900 (10)##procedures: values which specify a transformation
39000 from a set of input values to a result, possibly with some
39100 side-effects.
39200 .left margin 0
39300 .paragraph
39400 Constant values for most of these built-in data
39500 types have explicit representations in the EL1 language:
39600 .skip 1
39700 .left margin 10
39800 .indent -5
39900 .index TRUE
40000 .index FALSE
40100 (1)##Boolean constants are written TRUE and FALSE.
40200 .indent -5
40300 .skip 1
40400 (2)##Integer constants are sequences of digits,
40500 such as
40600 .skip 1
40700 .indent 5
40800 6#####1596####6600
40900 .skip 1
41000 Real constants
41100 are digit sequences including exactly one radix point:
41200 .skip 1
41300 #####2.71828#######.01745
41400 .skip 1
41500 Reals may also be written in 'scientific notation':
41600 .skip 1
41700 #####6.627E23######137E-2
41800 .skip 1
41900 where the suffix E followed
42000 by a signed integer N represents multiplication by
42100 a factor of ten to the power N:##137E-2 is the same as 1.37##.
42200 .indent -5
42300 .skip 1
42400 (3)##Character constants are denoted by a percent
42500 sign (%) followed by any character:
42600 .skip 1
42700 .indent 5
42800 %Z####%C####%=####%%
42900 .indent -5
43000 .skip 1
43100 (4)##There are no label constants. Label values
43200 are meaningful only in the context of compound forms
43300 (see section 2.5).
43400 .indent -5
43500 .skip 1
43600 .index NIL
43700 (5)##The only reference constant is NIL. It represents
43800 a pointer to the empty value.
43900 .indent -5
44000 .skip 1
44100 .index NOTHING
44200 (6)##The empty value is called NOTHING.
44300 .indent -5
44400 .skip 1
44500 .index BOOL
44600 .index INT
44700 .index REAL
44800 .index CHAR
44900 .index LABEL
45000 .index REF
45100 .index NONE
45200 .index mode
45300 .index SYMBOL
45400 .index STRING
45500 .index ROUTINE
45600 (7)##The mode constants represent the built-in
45700 data types of the language:##BOOL, INT, REAL, CHAR,
45800 LABEL, REF, NONE, MODE, SYMBOL, STRING, ROUTINE.
45900 One mode constant, ANY,
46000 plays a special role in the language (see section 2.10).
46100 There are no values with data type ANY.
46200 .indent -5
46300 .skip 1
46400 .index SYMBOL
46500 (8)##Symbol constants are strings of characters
46600 enclosed in double quotation marks:
46700 .skip 1
46800 .indent 5
46900 "ABC"######"1B16"#####"@#="#####
47000 .skip 1
47100 To include a double quotation mark in a symbol, one
47200 precedes it by a percent sign:
47300 .skip 1
47400 .break
47500 #####"%"Who are You?%", said the Caterpillar."
47600 .skip 1
47700 The same rule allows inclusion of percent sign:
47800 .skip 1
47900 ############"50%%##overlap"
48000 .skip 1
48100 .indent -5
48200 .index STRING
48300 (9)##String constants have the same form as symbol
48400 constants except that single quotation marks are
48500 used instead of double ones:
48600 .skip 1
48700 .indent 5
48800 'Johann Sebastian Bach'
48900 .indent 8
49000 'Rake%'s Progress'
49100 .skip 1
49200 .indent -6
49300 (10)##Procedure constants are procedure definitions.
49400 They are not elementary constants since they are
49500 composed of other forms. For example:
49600 .skip 1
49700 .indent 5
49800 EXPR(i:INT;INT)##(i+1)
49900 .skip 1
50000 .title
50100 .test page 15
50200 is a procedure constant which represents the transformation
50300 of an integer into its successor.
50400 The meaning of the syntax of procedures is explained
50500 in section 2.10.###########
50600 .skip 3
50700 .left margin 0
50800 .index variable
50900 2.3##VARIABLES
51000 .title 2.3##VARIABLES
51100
51200 .paragraph
51300 Variables give the programmer an abstract notation
51400 for the data his program manipulates. In EL1 every
51500 variable has a ∀name∩, a ∀mode∩, a ∀scope∩, and a
51600 ∀value∩. Only the value may change.
51700 .index identifier
51800 .paragraph
51900 A variable name is called an ∀identifier∩. EL1 has two kinds of identifiers:
52000 .skip 1
52100 .left margin 10
52200 .indent -5
52300 (1)##a sequence of consecutive letters (upper or lower case),
52400 digits, and backslashes (←\), the first of which is a letter,
52500 for example
52600 .skip 1
52700 .indent 5
52800 Igor##U235##real←\matrix##FUM
52900 .indent -10
53000 .skip 1
53100 .skip 1
53200 .indent -5
53300 .test page 10
53400 (2)##a sequence of characters from the set
53500 .skip 1
53600 .indent 2
53700 #.#←##$#*#+#-#/#<#=#>#?#@#→E∩#←↑#←!
53800 .skip 1
53900 .left margin 0
54000 Identifiers may be of any length. Upper and lower case
54100 letters are ↑¬\& considered identical: cat and CAT
54200 are distinct names. The user's identifiers must not conflict
54300 with certain reserved words of the language. Appendix D
54400 contains a list of these reserved words.
54500 .index scope
54600 .paragraph
54700 .index global variable
54800 Scope is the most subtle attribute of variables.
54900 Roughly speaking, the scope of a variable is the
55000 span of time over which it is defined. Some variables
55100 have meaning independent of the evaluation of a
55200 .index top-level variable
55300 particular program. These are called ∀top-level∩, or ∀global∩
55400 variables. Many global variables are pre-defined as part of the
55500 language. The set of globals may be expanded or contracted
55600 by the user (see section 3.2). Other variables are created
55700 and destroyed dynamically by programs as they run. These
55800 are called ∀local∩ variables. Their scope
55900 lasts only as long as an activation of the form
56000 .index local variable
56100 which creates them. Creation of local variables is discussed
56200 in section 2.5 and a more precise definition of local scope
56300 is given there. It should be emphasized here, however,
56400 that scope is no less a distinguishing feature
56500 of a variable than its name. Two variables may have the
56600 same name and may even be created by the same
56700 line of a program, and yet have different scope and different
56800 behavior.
56900 .paragraph
57000 .index mode
57100 A variable's mode describes the class of values the variable
57200 can assume. It is defined when the variable is created and remains
57300 fixed throughout its lifetime.
57400 .paragraph
57500 What can change, of course, is the variable's value, through
57600 .index assignment
57700 a built-in operation called ∀assignment∩. The format
57800 .test page 10
57900 of an assignment is[*]
58000 .footnote 7
58100 .skip 2
58200 ←←←←←←←←←←←←←←←←←←←←←←←←←←
58300 .skip 1
58400 .index <-
58500 [*]#Left-arrow (→E∩) and the symbol
58600 <- are predifined in ECL to have identical meaning.
58700 !
58800 .skip 1
58900 .indent 10
59000 form##<-##form
59100 .skip 1
59200 When this expression is evaluated, the value of the
59300 right-hand form replaces that of the left-hand form.
59400 For example, suppose temp and count are variables of mode
59500 INT. The assignment
59600 .skip 1
59700 .indent 10
59800 temp#<-#1079
59900 .skip 1
60000 gives temp the value 1079; temp's value can be passed on to the
60100 variable count by
60200 .skip 1
60300 .indent 10
60400 count#<-#temp
60500 .skip 1
60600 These assignments are legal because INT variables are
60700 being given INT values. In general, unless the modes
60800 of the two sides of an assignment agree, the evaluator of the
60900 program will signal an error. This kind of error is called
61000 .index type fault
61100 a ∀type fault∩. In certain cases, however, a right-hand value will be
61200 converted during assignment to match an expected mode.
61300 An INT will be converted to the equivalent REAL value on
61400 assignment to a REAL variable; a REAL will be ↑&rounded\& to the
61500 nearest INT, if necessary. Other permissible conversions are listed in Appendix F.
61600 .paragraph
61700 The value of an assignment is the value of its left-hand
61800 form ↑&after\& the assignment has been completed. Thus
61900 the value of
62000 .skip 1
62100 .indent 10
62200 count#<-#4.9
62300 .skip 1
62400 (where count remains an INT) is the INT value 5,
62500 not the REAL value 4.9. Moreover, in the (useless
62600 but legal) event that an assignment is itself the left-hand
62700 form of another assignment, the value of a variable may
62800 change twice, for example
62900 .title
63000 .test page 15
63100 .skip 1
63200 .indent 10
63300 (count#<-#2)#<-#50
63400 .skip 1
63500 results in a value of 50 for count.
63600 .skip 2
63700 .index operator
63800 2.4##OPERATOR EXPRESSIONS
63900 .title 2.4##OPERATOR EXPRESSIONS
64000 .paragraph
64100 EL1 provides the programmer with a set of built-in operators
64200 on built-in data types, and with facilities
64300 for defining both new data types and new operations.
64400 Operator expressions provide a notation for computation which
64500 resembles the formula notation of standard algebra and logic.
64600 .paragraph
64700 An operator expression is either
64800 .break
64900 .blank 1
65000 .indent 5
65100 .index prefix expression
65200 (1) a ∀prefix∩ expression, written
65300 .skip 1
65400 .indent 15
65500 identifier#####form
65600 .skip 1
65700 .break
65800 .indent 5
65900 .index infix expression
66000 (2) an ∀infix∩ expression, written
66100 .skip 1
66200 .indent 15
66300 form#####identifier#####form
66400 .blank 1
66500 .break
66600 .index nofix expression
66700 .blank 1
66800 .indent 2
66900 or (3) a ∀nofix∩ expression, written
67000 .break
67100 .blank 1
67200 .indent 15
67300 identifier
67400 .paragraph
67500 In a prefix expression, the identifier names an operation
67600 to be applied to the ∀operand∩ form, producing a value.
67700 For example, the identifier NOT is a built-in prefix
67800 operator which produces the logical inverse of a Boolean value; if b
67900 has mode BOOL and value FALSE, then NOT
68000 b produces TRUE.
68100 .paragraph
68200 An infix expression is evaluated by applying the operator
68300 named by the identifier to the two operand forms;
68400 producing a value. An example is +, the built-in
68500 infix operator which represents addition of two numbers
68600 to produce a number. If delta is an INT variable with value 4,
68700 then 6.3#+#delta has the REAL value 10.3.
68800 .paragraph
68900 A nofix expression is evaluated by calling the procedure named
69000 by the identifier with no arguments. For example, if f and g
69100 have the same procedure value, but f is nofix and g is a simple identifier
69200 (i.e. without fixity), then 1+f has the same meaning as 1+g().
69300 .paragraph
69400 A particular identifier can be used as both an infix and
69500 a prefix operator. Minus (-), for example, can be used either as
69600 arithmetic negation, or as the arithmetic difference operator. The
69700 meaning of a particular use is determined from context.
69800 In the expression -i-4, the first appearance of minus is
69900 prefix, while the second is infix
70000 with arguments -i and 4.
70100 .paragraph
70200 An operator may be nofix and infix, nofix and prefix, or all three.
70300 In these cases the context determines the meaning used--an
70400 infix meaning is used if possible, a prefix meaning if an infix
70500 meaning isn't appropriate, and a nofix meaning only if
70600 neither infix nor prefix meanings would result
70700 in well-formed expressions.
70800 .paragraph
70900 The built-in operators fall into seven categories. In the brief
71000 descriptions which follow, x and y represent numbers (INT or REAL),
71100 p and q represent Boolean values, and v and w represent values
71200 of any mode.
71300 .skip 1
71400 .left margin 10
71500 .test page 5
71600 .indent -5
71700 .index arithmetic operators
71800 (1)##↑&Arithmetic\& operators. These are written:
71900 .left margin 15
72000 .skip 1
72100 .index +
72200 .index -
72300 .index *
72400 .index /
72500 x#+#y###sum of x and y
72600 .break
72700 x#-#y###x less y
72800 .break
72900 ##-#x###negative of x
73000 .break
73100 x#*#y###product of x and y
73200 .break
73300 x#/#y###x divided by y
73400 .left margin 10
73500 .skip 1
73600 These operators use INT arithmetic and produce an INT
73700 result if and only if both operands are INT. Otherwise REAL
73800 arithmetic is used to yield a REAL result. The quotient of two INTs is obtained
73900 by truncating toward zero. That is, 5/3 becomes 1 and
74000 (-3)/2 is -1.
74100 .skip 1
74200 .indent -5
74300 .index Boolean operators
74400 (2)##↑&Boolean\& operators. These are:
74500 .skip 1
74600 .left margin 26
74700 .index AND
74800 .index OR
74900 .index NOT
75000 .indent -10
75100 p#AND#q###the logical product or conjunction
75200 of p and q; TRUE if and only if
75300 both are TRUE
75400 .skip 1
75500 .indent -10
75600 p#OR#q####the logical sum or disjunction of
75700 p and q: TRUE unless both
75800 are FALSE
75900 .skip 1
76000 .indent -10
76100 ##NOT#p###the logical negation of p, TRUE
76200 if and only if p
76300 is FALSE.
76400 .skip 1
76500 .left margin 10
76600 For AND and OR it is guaranteed that the
76700 second operand form will not be evaluated if the value of the
76800 first determines the outcome of the expression.
76900 .skip 1
77000 .indent -5
77100 .index arithmetic relational operators
77200 (3)##↑&Arithmetic relational\& operators. All are
77300 infix operators. They compare two numbers (INT or REAL)
77400 and produce a BOOL result.
77500 .skip 1
77600 .left margin 24
77700 .indent -10
77800 .index LT
77900 .index LE
78000 .index GT
78100 .index GE
78200 x#LT#y####TRUE exactly when x is strictly
78300 less than y.
78400 .skip 1
78500 .indent -10
78600 x#LE#y####TRUE exactly when x is less than
78700 or equal to y.
78800 .skip 1
78900 .indent -10
79000 x#GT#y####TRUE exactly when x is strictly
79100 greater than y.
79200 .skip 1
79300 .indent -10
79400 x#GE#y####TRUE exactly when x is greater
79500 than or equal to y.
79600 .left margin 10
79700 .skip 1
79800 If one but not both of the operands is an INT, it is converted to
79900 REAL before the comparison.
80000 .skip 1
80100 .indent -5
80200 .index general relational operators
80300 (4)##↑&General relational\& operators. These two operators
80400 test the equality of pairs of values which may be of
80500 any mode.
80600 .skip 1
80700 .left margin 23
80800 .indent -8
80900 .index =
81000 .index ←#
81100 v#=#w###TRUE if v and w have the same
81200 modes and equal values (see section 4.2 for a more exact definition);
81300 FALSE otherwise.
81400 .skip 1
81500 .indent -8
81600 v#←##w###The logical negation of v = w.
81700 .skip 1
81800 .left margin 10
81900 .indent -5
82000 (5)##∀Assignment∩, discussed in section 2.3, is
82100 an infix operation which can be applied to operands of
82200 any mode.
82300 .skip 1
82400 .indent -5
82500 .index ->
82600 (6)##∀Conditional execution∩. -> is an infix operator. The
82700 conditional is written form#->#form. In a conditional, the
82800 left form is called the ∀test clause∩, the
82900 right form is called the ∀consequent∩, and the right arrow
83000 may be read roughly as a causation or implication sign.
83100 The consequent is evaluated exactly when the
83200 test clause evaluates (possibly after conversion) to TRUE. In this case, the
83300 value of the form is the value of the consequent.
83400 Otherwise the value is NOTHING. This is further
83500 described in section 2.5.2.
83600 .left margin 0
83700 .paragraph
83800 In mathematics, notational conventions usually govern the
83900 interpretation of potentially ambiguous formulas. For example,
84000 ##sin#x→2∩#+#y##probably means##sin#(x→2∩)#+#y##and not##(sin#x)→2∩#+#y##or##sin#(x→2∩#+#y)##.
84100 In any case, parentheses can be used to resolve ambiguities.
84200 .paragraph
84300 Similarly in EL1, any form may be
84400 replaced by the same form in parentheses, so the programmer can group sub-expressions explicitly. To retain the convenience
84500 .index precedence
84600 of notational conventions, however, rules of ∀precedence∩
84700 are used when an expression has not been completely broken
84800 into sub-expressions. The rules are:
84900 .skip 1
85000 .left margin 10
85100 .indent -5
85200 (1)##Prefix operators always take precedence over infix operators.
85300 .skip 1
85400 .indent -5
85500 (2)##Every infix operator is given a numeric precedence.
85600 Operations of higher precedence are evaluated first.
85700 .skip 1
85800 .indent -5
85900 (3)##Every infix operator is designated either
86000 .index left-association
86100 .index right-association
86200 ∀left-associative∩ or ∀right-associative∩. When two or more
86300 consecutive operators have the same precedence and are in conflict
86400 (i.e. appear to share operands) the conflict is resolved by a
86500 left-to-right scan through the sub-expression: each
86600 left-associative operator takes the operand immediately following
86700 as its right operand; each right-associative operator takes
86800 the rest of the sub-expression as its right operand.
86900 .left margin 0
87000 .paragraph
87100 Rule (1) means that, for example, -i-4 is interpreted as
87200 (-i)-4. The relational operators take precedence over
87300 AND, so by rule (2)
87400 .skip 1
87500 .indent 10
87600 x#GT#y##AND#v#=#w
87700 .skip 1
87800 means
87900 .skip 1
88000 .indent 10
88100 (x#GT#y)#AND#(v=w)
88200 .skip 1
88300 .test page 8
88400 Since * takes precedence over + and both take precedence
88500 over <-, the form
88600 .skip 1
88700 .indent 10
88800 u#<-#x*y#+#z*a
88900 .skip 1
89000 is parenthesized
89100 .skip 1
89200 .indent 10
89300 u#<-#((x*y)#+#(z*a))
89400 .skip 1
89500 For precedences of all built-in infix operators, consult
89600 section 4.
89700 .paragraph
89800 The built-in operator * is left-associative.
89900 Thus by rule (3), a*b*c means (a*b)*c. Multiple assignments,
90000 however, associate to the right:
90100 .skip 1
90200 .indent 10
90300 p#<-#q<-#r#<-#FALSE
90400 .skip 1
90500 is evaluated as if it were
90600 .skip 1
90700 .indent 10
90800 p#<-#(q#<-#(r#<-#FALSE))
90900 .paragraph
91000 Although rules (1) through (3) completely specify
91100 the association of operands with operators, they do not
91200 specify which operand of an operator will be evaluated
91300 first. Only for AND and OR have we said that one
91400 necessarily precedes the other. For the other built-in
91500 operators, the order of operand evaluation is specifically
91600 undefined. Different evaluators of the expression
91700 (a*b)#+#(c/d) are free to choose whether to multiply
91800 a by b before or after
91900 dividing c by d.
92000 As will be seen in section 4.4, the
92100 programmer can define his own operators, complete with
92200 precedence, and right or left associativity. He can likewise
92300 choose an order of operand evaluation or leave the order
92400 unspecified.
92500 .paragraph
92600 Finally, before considering more intricate forms, it
92700 is well to note an intrinsic difference in EL1, as in most
92800 programming languages, between the values represented by identifiers,
92900 like x, and those represented by constants or by expressions
93000 like y+1. It makes sense to assign a new value to x, e.g. x<-y+1; but an
93100 assignment like y+1<-x, although legal in EL1 and quite harmless,
93200 is useless. The value of x is persistent and reusable; a
93300 change made to x can have an effect on the later evaluation of
93400 .index proper object
93500 the program. We call such values ∀proper objects∩. We
93600 will see shortly that forms other than simple identifiers can
93700 represent proper objects. Forms like y+1, TRUE, or 1.414
93800 which are not useful targets for assignment are called
93900 ∀pure values∩. All the built-in operators except assignment,
94000 non-deterministic assignment (see section 4.9),
94100 and conditional execution (see section 2.3) produce pure values.