Download STK Reference manual

Transcript
STk Reference Manual
38
(define E (let ((a 1) (b 2))
(let ((c 3))
(the-environment))))
(car (environment->list E)) =⇒ ((c . 3))
(cadr (environment->list E))=⇒ ((b . 2) (a . 1))
(procedure-environment procedure)
procedure
Returns the environment associated with procedure . Procedure-environment returns #f if
procedure is not a closure.
(define foo (let ((a 1)) (lambda () a)))
(car (environment->list
(procedure-environment foo)))
=⇒ ((a . 1))
(module-environment module)
procedure
Returns the environment associated to the module module.
(define-module M
(define a 1))
(car (environment->list
(module-environment (find-module ’M))))
=⇒ ((a . 1))
(symbol-bound? symbol)
(symbol-bound? symbol environment)
procedure
procedure
Returns #t if symbol has a value in the given environment, otherwise returns #f. Environment
may be omitted, in which case it defaults to the global environment.
6.15
Macros
STk provides low level macros.
Note: STk macros are not the sort of macros defined in the appendix of R4RS, but rather the macros
one can find in most of Lisp dialects.
(macro formals body)
syntax
Macro permits to create a macro. When a macro is called, the whole form (i.e. the macro
itself and its parameters) is passed to the macro body. Binding association is done in the
environment of the call. The result of the binding association is called the macro-expansion.
The result of the macro call is the result of the evaluation of the macro expansion in the call
environment.