Macros: macro.ss

Next: Match: match.ss Up: MzLib Libraries Previous: Invoking with Exports to

## Macros: `macro.ss`

Files: `macro.ss`

`(class-asi superclass clauses )` SYNTAX

Like `class`, but the initialization arguments are automatically passed on to the superclass initialization procedure.

`(class*-asi superclass interfaces clauses )` SYNTAX

Like `class*`, but the initialization arguments are automatically passed on to the superclass initialization procedure.

`(`evcase` key-expr `(`value-expr body-expr `)` )` SYNTAX

The `evcase` form is similar to `case`, except that expressions are provided in each clause instead of a sequence of data. After key-expr is evaluated, each value-expr is evaluated until a value is found that is `eqv?` to the key value; when a matching value is found, the corresponding body-exprs are evaluated and the value(s) for the last is the result of the entire `evcase` expression.

A value-expr can be the special identifier `else`. This identifier is recognized as in `case` (see section 3.2).

`(let+ clause body-expr )` SYNTAX

A new binding construct that specifies scoping on a per-binding basis instead of a per-expression basis. It helps eliminate rightward-drift in programs. It looks a lot like `let`, except each clause has an additional keyword tag before the binding variables.

Each clause has one of the following forms:

- `(val variable expr)` binds variable non-recursively to expr.
- `(rec variable expr)` binds variable recursively to expr.
- `(vals (variable expr) )` the variables are bound to the exprs. The environment of the exprs is the environment active before this clause.
- `(recs (variable expr) )` the variables are bound to the exprs. The environment of the exprs includes all of the variables.
- `(_ expr )` evaluates the exprs without binding any variables.

The clauses bind left-to-right. Each variable above can either be an identifier or `(values variable )`. In the latter case, multiple values returned by the corresponding expression are bound to the multiple variables.

Examples:

``

      (let+ ([val (values x y) (values 1 2)])
         (list x y)) ; => (1 2)
      (let ([x 1])
         (let+ ([val x 3]
                [val y x])
            y)) ; => 3

`(`local` `(`definition `)` body-expr )` SYNTAX

This is a binding form similar to `letrec`, except that each definition is a `define-values`, `define`, or `define-struct` expression (before macro-expansion). The body-exprs are evaluated in the lexical scope of these definitions.

`(nand expr )` SYNTAX

Returns `(not (and expr ))`.

`(nor expr )` SYNTAX

Returns `(not (or expr ))`.

`(opt-lambda formals body-expr )` SYNTAX

The `opt-lambda` form is like `lambda`, except that default values are assigned to arguments (C++-style). Default values are defined in the formals list by replacing each variable by `[variable default-value-expression]`. If an variable has a default value expression, then all (non-aggregate) variables after it must have default value expressions. A final aggregate variable can be used as in `lambda`, but it cannot be given a default value. Each default value expression is evaluated only if it is needed. The environment of each default value expression includes the preceding arguments.

For example: ``

      (define f
         (opt-lambda (a [b (add1 a)] . c)
            ...))

Here, `f` is a procedure which takes at least one argument. If a second argument is specified, it is the value of `b`, otherwise `b` is `(add1 a)`. If more than two arguments are specified, then the extra arguments are placed in a new list that is the value of `c`.

`(recur name bindings body-expr )` SYNTAX

This is equivalent to a named `let`: `(let name bindings body-expr )`.

`(send* obj msg )` SYNTAX

Calls multiple methods of obj (in the specified order). Each msg should have the form: ``

      (name params ...)

where name is the method name. For example: `

      (send* edit (begin-edit-sequence)
                  (insert "Hello")
                  (insert #\newline)
                  (end-edit-sequence))

` is the same as `

      (let ([e edit])
        (send e begin-edit-sequence)
        (send e insert "Hello")
        (send e insert #\newline)
        (send e end-edit-sequence))

`

`(signature->symbols name)` SYNTAX

Expands to the ``exploded'' version (see section 7.4.3) of the signature currently bound to name (where name is an unevaluated identifier). The expansion-time value of name (see section 13.3) must have the shape of an exploded signature.

Next: Match: match.ss Up: MzLib Libraries Previous: Invoking with Exports to