next up previous
Next: Input/Output Up: User-level Constructs Previous: Expressions

Static Data

Two constructs, defword and defarray, allow single words and regions of memory to be named and initialized to definite values when the program is loaded.



defword

Define a global variable.
Syntax:

 (defword  name value)

Elements:
name ---
An alphanumeric symbol naming this variable. Must be distinct from the names of routines and other static data items.
value ---
A 32-bit constant integer giving the initial value of the variable.

Description:

Defword is intended for use as a top-level form but actually it may appear anywhere a statement may appear. When executed as a statement it does nothing.

Defword defines the name name to globally refer to a particular unique memory location, whose initial value when the program is loaded is value. This meaning of name can be shadowed within subroutines that have name as a formal argument, or within the body of a let statement that binds that name. The name can be used as a place in data-modification statements.

Actually the name will only be recognized to refer to the memory location at statements in the program that occur textually after the defword declaration.



defarray

Define a global array.
Syntax:

 (defarray  name

value value ... )

Elements:
name ---
Unique alphanumeric name for the array.
value, value, ... ---
Integer constants giving the initial values of all the array elements.

Description:

Defarray is intended for use as a top-level form, but actually it may appear anywhere a statement may appear. When executed as a statement it does nothing.

Defarray sets aside a contiguous region of memory, containing a number of words equal to the number of value arguments, and defines the name name to globally (that is, after the defarray) refer to the address of the first word in the region. The words are initialized to the given values when the program is first loaded. Name can be used as an array in array-dereference operations. It is a compile-time error to attempt to change the value of name. However, name can be shadowed by subroutine arguments and local variable declarations.



next up previous
Next: Input/Output Up: User-level Constructs Previous: Expressions



Michael Frank
Mon Nov 3 16:33:38 EST 1997