[Next] [Previous] [Up] [Top] [Contents] [Index]

14 The Built-In Macros and Special Operators

Local Declarations

Local declarations are used to create bindings or install handlers that are active for the remainder of the innermost body containing the declaration. Bindings created by local declarations can be referenced only in the remaining program text of the body. Handlers installed are active while the execution of the remainder of the body is active, which includes the time during which any functions called from the remainder of the body are active.
Local Declarations (continued)
Macro DescriptionPage
let Creates and initializes new local bindings within the smallest enclosing implicit body.376
local Creates new local bindings within the smallest enclosing implicit body and initializes them to local methods which can be self-recursive and mutually-recursive.377
let handler Establishes a condition handler for the duration of the execution of smallest enclosing implicit body.378

let [Local Declaration]


Creates and initializes new local bindings within the smallest enclosing implicit body.

Macro Call:
let variables = init ;

Arguments:
variables variablebnf | ( variable-listbnf )

init
expressionbnf

Description:
let creates local bindings for the variables, and initializes them to the values returned by init. The bindings are visible for the remainder of the smallest enclosing implicit body.

The first value returned by the init is bound to the first variable, the second value to the second variable, etc. The last variable may be preceded by #rest, in which case it is bound to a sequence containing all the remaining values.

Each variable is a variable-name or a variable-name followed by a specializer.

If more than one binding is defined, the variables are enclosed in parentheses and separated by commas.

let start = 0;
let (whole-part, remainder) = truncate(amount);
let (first-value, #rest rest-values) = get-inital-values();
Local variables may be specialized. This ensures that their value will always be of a given type. An attempt to initialize or assign the variable to a value not of that type will signal an error of type <type-error>.

let elapsed-time :: <integer> = 0;
let the-front-window :: <window> = front-window();
let(whole-part :: <integer>, remainder :: <real>) = truncate(amount);

local [Local Declaration]


Creates new local bindings within the smallest enclosing implicit body and initializes them to local methods which can be self-recursive and mutually-recursive.

Macro Call:
local { [ method ] name parameter-list [ body ] end [ method ] [ name ] } ,+

Arguments:
name variable-namebnf

parameter-list
parameter-listbnf

body
bodybnf

Description:
local is creates local methods which may be mutually recursive and self-recursive.

Each name creates a new local binding. The binding is initialized to a new method specified by the parameter-list and body. In addition to being visible for the remainder of the smallest enclosing implicit body, the bindings created for the names are visible to the parameter-lists and bodies of all the methods created by the local declaration.

The parameter-list is a standard method parameter list. A complete description of parameter lists is given in "Parameter Lists" on page 82.

The body is an implicit body.

let handler [Local Declaration]


Establishes a condition handler for the duration of the execution of smallest enclosing implicit body.

Macro Call:
let handler condition = handler

Arguments:
condition type | ( type { ,option }*)

type
expressionbnf

option
test-option | init-option

test-option
test: expressionbnf

init-option
init-arguments: expressionbnf

handler
expressionbnf

Description:
let handler establishes a new condition handler which is in effect for the duration of the execution of the remainder of the smallest enclosing implicit body. Unlike the local declarations let and local, let handler does not create any bindings.


Dylan Reference Manual - 17 OCT 1995
[Next] [Previous] [Up] [Top] [Contents] [Index]

Generated with Harlequin WebMaker