Next: iklib syntaxes optim-of, Previous: iklib syntaxes properties, Up: iklib syntaxes [Index]
This syntax is mostly for interactive use. Fully expand the given expression in the current lexical environment and return a symbolic expression representing the resulting invoke code. The expression is not evaluated, only expanded; this means that the expansion side effects are performed.
As a special case if ?expr is recognised as a define or
define* syntax use:
(define . ?stuff) (define* . ?stuff)
the expansion will be performed as if ?expr is:
(internal-body (define . ?stuff) (void)) (internal-body (define* . ?stuff) (void))
and the definition extracted from the result and reformatted.
Example session at the REPL:
vicare> (import (vicare expander tags))
vicare> (print-gensym #f)
vicare> (expansion-of (+ 1 2))
$1 = ((primitive +) (quote 1) (quote 2))
vicare> (expansion-of (lambda (a b) (+ a b)))
$1 = (lambda (a b) ((primitive +) a b))
vicare> (internal-body
(define-syntax (doit stx)
(syntax-case stx ()
((_ ?a ?b)
#'(vector ?a ?b))))
(expansion-of (doit 1 2)))
$1 = ((primitive vector) (quote 1) (quote 2))
vicare> (expansion-of (define (fun a) (+ 1 a)))
$1 = (define fun (lambda (a) ((primitive +) (quote 1) a)))
This syntax is mostly for interactive use. Given the identifier of a locally defined macro keyword: expand into a quoted symbolic expression representing the expanded macro transformer.
Example session at the REPL:
vicare> (print-gensym #f) vicare> (define-syntax syn (lambda (stx) #'(void))) vicare> (visit-code-of syn) $1 = (lambda (stx) #<syntax expr=(void))
Like expansion-of, but wrap the input expression as follows:
(internal-body ?expr0 ?expr … (void))
this allows the expansion of definition forms.
Next: iklib syntaxes optim-of, Previous: iklib syntaxes properties, Up: iklib syntaxes [Index]