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


Typed Variables

The syntactic type typed-variable is defined in the compiler module. It has slots for name and type. The name is the name of a variable. The term "variable" is used for traditional reasons, although almost all uses of typed-variable create fixed definitions, so the "variable" cannot actually vary. The type is an expression that must evaluate to a type. The value of the variable is restricted to be a member of this type.

The syntax for a typed-variable is a variable name optionally followed by the bound particle is and a type specifier (see the next section). If just a variable name is specified with no type restriction, the type defaults to anything.

A variable name consists of either a name that is not punctuation and is not visibly defined as an operator or macro, or a backslash followed by any name or a string that gets converted to a name.

Examples:

def pi = 3.14159
def pi is float = 3.14159
def y is integer-above(0) or false := z
def w is 64 bits = 1234567890


Previous page   Table of Contents   Next page