The #%namespaced hook
#%namespaced
1 Checking if languages support #%namespaced
key:  supports-namespaced?
8.12

The #%namespaced hook🔗ℹ

 (require namespaced-transformer)
  package: namespaced-transformer-lib

The #%namespaced form adds a form of explicit identifier namespacing, designed to be used in contexts where syntax objects must be created without lexical scope, such as when implementing read-syntax for a language. This is especially useful for “language extensions”, also known as “meta languages”, such as languages created using make-meta-reader. Since language extensions do not have control over the lexical environment that the produced syntax objects will be evaluated in, it is difficult to create hygienic extensions that adjust semantics. If the “host” language provides #%namespaced, then language extensions can use it to safely hook into the result by defining ordinary syntax transformers.

syntax

(#%namespaced module-path form)

 
form = id
  | (id . args)
Equivalent to form, except that id’s lexical context is adjusted to refer to an identifier imported from module-path. All source locations and syntax properties in form are preserved, and if form is a list, then args are passed through entirely unmodified.

1 Checking if languages support #%namespaced🔗ℹ

 (require namespaced-transformer/info-key)
  package: namespaced-transformer-lib

value

key:supports-namespaced? : any/c

The key:supports-namespaced? value is an opaque key designed to be used as the first argument to a language’s get-info procedure. A base language that provides #%namespaced should provide a get-info procedure that returns #t when given key:supports-namespaced? as a key. See also read-language for an example of how get-info is used.