Previous: , Up: expander lexenv   [Index]


15.3.9 Lexical environment inspection

The following syntactic bindings are exported by the library (vicare expander).

Function: syntactic-identifier->label id

Given the syntactic identifier id search its sequence of rib for a syntactic binding having the same source–name and marks. If successful: return the syntactic binding’s label gensym; otherwise return #f.

(import (vicare) (prefix (vicare expander) xp::))

(xp::syntactic-identifier->label #'display)
⇒ #{lab.display |PeEZ8c2>r<R&lTRg|}
Function: label->syntactic-binding-descriptor label lexenv

Look up the symbol label in the lexenv as well as in the global environment. If an entry with key label is found: return the associated syntactic binding descriptor; if no matching entry is found, return one of the special descriptors:

(displaced-lexical . #f)

If the label is unbound in lexenv.

(displaced-lexical . ())

If the argument label is invalid.

If the binding descriptor represents a fluid syntax or synonym syntax: follow through and return the innermost redefinition of the binding.

(import (vicare) (prefix (vicare expander) xp::))

(begin-for-syntax
  (xp::label->syntactic-binding-descriptor
      (xp::syntactic-identifier->label #'display)
      (xp::current-inferior-lexenv)))
⇒ (core-prim . display)

(begin-for-syntax
  (xp::label->syntactic-binding-descriptor
      'label
      (xp::current-inferior-lexenv)))
⇒ (displaced-lexical . #f)

(begin-for-syntax
  (xp::label->syntactic-binding-descriptor
      123
      (xp::current-inferior-lexenv)))
⇒ (displaced-lexical . ())
Function: label->syntactic-binding-descriptor/no-indirection

Like label->syntactic-binding-descriptor, but if the binding descriptor represents a fluid syntax or a synonym syntax: do not follow through; instead return the binding descriptor of the fluid or synonym syntax definition.

(import (vicare)
   (prefix (vicare expander) xp::))

(define-fluid-syntax flu
  (identifier-syntax 123))

(begin-for-syntax
  (xp::label->syntactic-binding-descriptor
    (xp::syntactic-identifier->label #'flu)
    (xp::current-inferior-lexenv)))
⇒ (local-macro . (?procedure . ?sexp))

(begin-for-syntax
  (xp::label->syntactic-binding-descriptor/no-indirection
    (xp::syntactic-identifier->label #'flu)
    (xp::current-inferior-lexenv)))
⇒ ($fluid . lab.flu)