Environments

Environments are first class objects in STk. The following primitives are defined on environments.





`=̀13`(ndexfile(index-entry "environment?" "tt" main )environment?obj)
procedure
Returns #t if obj is an environment, otherwise returns #f.





`=̀13`(ndexfile(index-entry "the-environment" "tt" main )the-environment)
procedure
Returns the current environment.





`=̀13`(ndexfile(index-entry "global-environment" "tt" main )global-environment)
procedure
Returns the ``global'' environment (i.e. the toplevel environment). ndexfile(index-entry "top level environment" "rm" main )





`=̀13`(ndexfile(index-entry "parent-environment" "tt" main )parent-environmentenv)
procedure
Returns the parent environment of env. If env is the ``global'' environment (i.e. the toplevel environment), ndexfile(index-entry "parent-environment" "tt" aux )parent-environment returns #f.





`=̀13`(ndexfile(index-entry "environment->list" "tt" main )environment->listenvironment)
procedure
Returns a list of a-lists, representing the bindings in environment. Each a-list describes one level of bindings, with the innermost level coming first. $\Longrightarrow$
$\Longrightarrow$ unspecified error makeotherˆ`=̀13`


          gobblecr(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))






`=̀13`(ndexfile(index-entry "procedure-environment" "tt" main )procedure-environmentprocedure)
procedure
Returns the environment associated with procedure. ndexfile(index-entry "Procedure-environment" "tt" aux )Procedure-environment returns #f if procedure is not a closure. $\Longrightarrow$
$\Longrightarrow$ unspecified error makeotherˆ`=̀13`


          gobblecr(define foo (let ((a 1)) (lambda () a)))(car (environment->list          (procedure-environment foo)))                       ((a . 1))





`=̀13`(ndexfile(index-entry "symbol-bound?" "tt" main )symbol-bound?symbol)
procedure
`=̀13`(ndexfile(index-entry "symbol-bound?" "tt" main )symbol-bound?symbol environment)
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.