Programming Language for Old Timers


by David A. Moon
February 2006 .. September 2008

Comments and criticisms to dave underscore moon atsign alum dot mit dot edu.


Previous page   Table of Contents   Next page


Summary Of Built-Ins

This section is the equivalent of explaining all the constructs built into the compiler in other languages. But here these are simply definitions exported by the PLOT module. You can import them into your own module or not as you prefer. Most of these constructs have straightforward definitions within the language. A few of them involve intrinsic methods that are known to the compiler.

Standard operators, with their precedence:

+ 120 addition, array concatenation
- 120 subtraction
* 130 multiplication
/ 130 division
mod 130 modulo
= 110 equality
< 110 less than
> 110 greater than
<= 110 less than or equal
>= 110 greater than or equal
~= 110 not equal
eq 110 same object
~eq 110 not same object
:= 10 assignment
<< 140 left shift
>> 140 right shift
is 180 instance of
as 180 cast
.. 100 range given min and max
& 150 bitwise and
| 150 bitwise or
~ 160 bitwise complement
and 40 logical and
or 30 logical or
not 50 logical not

Standard infix macros, with their precedence:

function ( arguments ) 200 call
collection [ subscripts ] 200 subscripting
object . function-name 300 one-argument Smalltalk-style function call
object . function-name ( arguments ) 300 multi-argument Smalltalk-style function call

Standard prefix macros:

( expression ) grouping
fun [name] ( parameters ) [ is result-type ] body function constructor
[ element, element, ... ] list constructor
[ key => value, key => value, ... ] dictionary constructor
# data quoted data
` template ` token sequence constructor from template

Standard prefix macros considered statements: (explained below)

if test [then] body else body conditional
do body grouping
block body grouping and scoping
cleanup cleanup body cleanup on exit
catch name body permit early exit
while test body iteration
until test body iteration
for ... body complex iteration
case .... case dispatch
with-slots .... abbreviated syntax for slot references
def variable definition
defun function method definition
defoperator operator definition
defmacro macro definition
defparser parser definition
defsyntax parser definition, accepts already-parsed form
defmodule module definition
defclass class definition
defprotocol protocol definition
require method requirement

Particles Used by Standard Macros:

, list element separator
=> input/output separator
\ denaturer, prevents next token from being special
# quote
= separates name and value
:= separates name and value, is assignable
: annotation
? pattern/template variable
?: pattern/template variable, syntactic type same as name
?= bound particle in pattern, anaphoric name in template
{ } pattern grouping
[ ] pattern optional
^ ^^ ^= ^^= pattern linebreaks
| pattern alternative separator
& pattern suffix separator
{ }* pattern repeat zero or more times
{ }+ pattern repeat one or more times
[ ]* each alternative appears at most once, in any order
[ ]+ same but at least one alternative must appear
is type restriction (bound)
then
else
in
from
downfrom
above
below
by
while
until


Previous page   Table of Contents   Next page