Next: , Up: expander lexenv imported   [Index]


15.3.5.1 Inspecting descriptors

We must remember that a syntactic binding’s descriptor is a pair with format:

(?binding-type . ?binding-value)

first let’s create a library:

(library (demo)
  (export var)
  (import (vicare))
  (define var "ciao"))

then let’s create an environment object with the (demo) library:

(define env (environment '(demo)))

finally let’s look at the descriptor:

(define-values (label descriptor)
  (environment-binding 'var env))

(define lex/loc-gensym
  (cddr descriptor))

(print-gensym #f)

descriptor
⇒ (global . (#<library (demo)> . lex/loc.var))

(symbol-value label)
⇒ (global . (#<library (demo)> . lex/loc.var))

(eq? descriptor (symbol-value label))
⇒ #t

(symbol-value lex/loc-gensym)
⇒ "ciao"

where lex/loc.var is both the lexical gensym and the storage location gensym of the exported variable; we can also import the library and try to expand some code:

(import (demo))
(print-gensym #f)
(expansion-of var)
⇒ lex/loc.var