Next: , Previous: , Up: lang   [Index]


1.19 Instantiable bodies

Instantiable bodies are sequences of forms defined in a lexical context and usable in another lexical context with some preliminary processing. The following syntactic bindings are exported by the library (vicare language-extensions instantiable-bodies).

Syntax: define-instantiable-body ?definer . ?body

Define a new syntax bound to the syntactic identifier ?definer which, when used, expands to the ?body forms. The defined syntax must be used as follows:

(?definer
  ((?from ?to) ...))

where ?from must be a syntactic identifier and ?to can be any form. Before the expansion: all the occurrences of the syntactic identifiers ?from are replaced by the associated syntactic identifiers ?to.

Here is a simple example:

(define-instantiable-body definer
  (define (fun)
    const))

(definer ((fun doit) (const 123)))

(doit)  ⇒ 123

the use of the syntax definer expands into:

(define (doit)
  123)