Next: , Previous: , Up: iklib expander   [Index]


6.14.7 Fluid syntaxes

Fluid syntaxes are macro bindings that can be temporarily redefined while expanding a sequence of forms:

(import (vicare))

(define-fluid-syntax ciao
  (identifier-syntax "ciao"))

ciao    ⇒ "ciao"

(fluid-let-syntax ((ciao (identifier-syntax "hello")))
  ciao) ⇒ "hello"

(fluid-let-syntax ((ciao (identifier-syntax "ohayo")))
  ciao) ⇒ "ohayo"

ciao    ⇒ "ciao"
Syntax: define-fluid-syntax ?keyword ?expr

Like define-syntax define a new syntax binding the transformer to ?keyword, but mark ?keyword as fluid so that later it can be rebound by fluid-let-syntax.

Syntax: fluid-let-syntax ((?keyword ?expr) ...) ?body0 ?body

Similar, but not equal, to let-syntax; rather than defining new ?keyword bindings, temporarily rebind the keywords to new transformers while expanding the ?body forms. The given ?keyword must be already bound to fluid syntaxes defined by define-fluid-syntax.

There are two differences between fluid-let-syntax and let-syntax: fluid-let-syntax must appear in expression context only; the internal ?body forms are not spliced in the enclosing body.