Next: iklib eval, Previous: iklib shared, Up: iklib [Index]
The following bindings are exported by the library (vicare).
Return #t if env is a lexical environment object.
Return #t if env is a non–interaction lexical environment
object object.
Return #t if env is an interaction lexical environment object
object.
When called with no arguments: return an environment object representing
the environment active at the REPL; to be used as argument for
eval.
When called with the argument env, which must be an environment object: set env as interaction environment.
Build and return a new interaction environment object. When no argument
is given: the returned environment is initialised by importing the
library (vicare). When libname is used it must be a
library name specification: the returned environment is initialised with
the specified library.
Notice that it is possible to use interaction environments to have persistent bindings:
(begin
(eval '(define c 3)
(interaction-environment))
(eval 'c
(interaction-environment)))
⇒ 3
(begin
(eval '(begin
(define a 1)
(define b 2))
(interaction-environment))
(eval '(list a b)
(interaction-environment)))
⇒ (1 2)
(let ((env (new-interaction-environment)))
(eval '(begin
(define a 1)
(define b 2))
env)
(eval '(list a b)
env))
⇒ (1 2)
and it is also possible to import additional libraries:
(eval '(import (vicare posix))
(interaction-environment))
At the top–level of an interaction environment, it is possible to redefine syntactic bindings:
(let ((env (new-interaction-environment '(rnrs base))))
(eval '(define d 3) env)
(eval '(define d 4) env)
(eval 'd env))
⇒ 4
(let ((env (new-interaction-environment '(rnrs base))))
(eval '(begin
(define x 1)
(define y 2)
(define z 3))
env)
(eval '(begin
(define x 10)
(define y 20)
(define z 30))
env)
(eval '(list x y z)
env))
⇒ (10 20 30)
(let ((env (new-interaction-environment '(rnrs base))))
(eval '(begin
(define-syntax x (identifier-syntax 1))
(define-syntax y (identifier-syntax 2))
(define-syntax z (identifier-syntax 3)))
env)
(eval '(begin
(define-syntax x (identifier-syntax 10))
(define-syntax y (identifier-syntax 20))
(define-syntax z (identifier-syntax 30)))
env)
(eval '(list x y z)
env))
⇒ (10 20 30)
(let ((env (new-interaction-environment '(vicare))))
(eval '(begin
(define-fluid-syntax x (identifier-syntax 1))
(define-fluid-syntax y (identifier-syntax 2))
(define-fluid-syntax z (identifier-syntax 3)))
env)
(eval '(begin
(define-fluid-syntax x (identifier-syntax 10))
(define-fluid-syntax y (identifier-syntax 20))
(define-fluid-syntax z (identifier-syntax 30)))
env)
(eval '(list x y z)
env))
⇒ (10 20 30)
(let ((env (new-interaction-environment '(vicare))))
(eval '(begin
(begin-for-syntax
(define a 1)
(define a 2))
(define-syntax doit
(lambda (stx) a)))
env)
(eval '(doit) env))
⇒ 2
At the top–level of an interaction environment, it is possible to shadow syntactic bindings imported from a library:
(let ((env (new-interaction-environment '(vicare))))
(eval '(define display 123) env)
(eval 'display env))
⇒ 123
(let ((env (new-interaction-environment '(vicare))))
(eval '(begin
(begin-for-syntax
(define display 123))
(define-syntax doit
(lambda (stx) display)))
env)
(eval '(doit) env))
⇒ 123
Return a list of symbols representing the names of the bindings from
env, which must be an environment. The name in position i
in the returned list is associated to the label in position i in
the list returned by environment-labels.
For example, the following program prints all the bindings in the
library (vicare language-extensions):
#!r6rs (import (vicare)) (for-each pretty-print (environment-symbols (environment '(vicare language-extensions)))) (flush-output-port (current-output-port))
Return a list of symbols representing the labels of the bindings from
the given non–interaction environment. The label in position i
in the returned list is associated to the name in position i in
the list returned by environment-symbols.
Return the list of library records representing the libraries
forming the non–interaction environment env.
Search the symbol sym in the non–interaction environment env; if sym is the public name of a binding in env return 2 values: the label associated to the binding, the list of values representing the binding. If sym is not present in env return false and false.
(environment-binding 'display (environment '(vicare)))
⇒ #{g870 |/1tY778AJ%G&f2UX|} (core-prim . display)
Next: iklib eval, Previous: iklib shared, Up: iklib [Index]