# 12.2 Syntax Object Content
If srcloc is not #f, a [srcloc](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._srcloc%29%29) instance, or a [syntax object](syntax-model.html#%28tech._syntax._object%29), it must be a list or vector of five elements that correspond to [srcloc](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._srcloc%29%29) fields.
Graph structure is not preserved by the conversion of v to a [syntax object](syntax-model.html#%28tech._syntax._object%29). Instead, v is essentially unfolded into a tree. If v has a cycle through pairs, vectors, boxes, immutable [hash tables](hashtables.html#%28tech._hash._table%29), and immutable [prefab](structures.html#%28tech._prefab%29) structures, then the [exn:fail:contract](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29) exception is raised.
The ignored argument is allowed for backward compatibility and has no effect on the returned syntax object.
Changed in version 8.2.0.5 of package base: Allow a [srcloc](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._srcloc%29%29) value as a srcloc argument.
> ```
(syntax-binding-set)	→
(-> syntax-binding-set)


# 12.2 Syntax Object Content
```
A syntax binding set supports explicit construction of binding information for a syntax object. Start by creating an empty binding set with syntax-binding-set, add bindings with syntax-binding-set-extend, and create a syntax object that has the bindings as its lexical information using syntax-binding-set  →  syntax.

The first three arguments to syntax-binding-set-extend establish a binding of symbol at phase to an identifier that is defined in the module referenced by mpi. Supply source-symbol to make the binding of symbol refer to a different provided variable from mpi, and so on; the optional arguments correspond to the results of identifier-binding.

Added in version 7.0.0.12 of package base.

> ```
(datum-intern-literal v)   →   any/c
  v : any/c```

Converts some values to be consistent with an [interned](reader.html#%28tech._interned%29) result produced by the default reader in [read-syntax](Reading.html#%28def._%28%28quote._~23~25kernel%29._read-syntax%29%29) mode.

If v is a [number](numbers.html#%28tech._number%29), [character](characters.html#%28tech._character%29), [string](strings.html#%28tech._string%29), [byte string](bytestrings.html#%28tech._byte._string%29), or [regular expression](regexp.html#%28tech._regular._expression%29), then the result is a value that is [equal?](Equality.html#%28def._%28%28quote._~23~25kernel%29._equal~3f%29%29) to v and [eq?](Equality.html#%28def._%28%28quote._~23~25kernel%29._eq~3f%29%29) to a potential result of the default reader. (Note that mutable strings and byte strings are [interned](reader.html#%28tech._interned%29) as immutable strings and byte strings.)

If v is an [uninterned](symbols.html#%28tech._uninterned%29) or an [unreadable symbol](symbols.html#%28tech._unreadable._symbol%29), the result is still v, since an [interned](reader.html#%28tech._interned%29) symbol would not be [equal?](Equality.html#%28def._%28%28quote._~23~25kernel%29._equal~3f%29%29) to v.

The conversion process does not traverse compound values. For example, if v is a [pair](pairs.html#%28tech._pair%29) containing strings, then the strings within v are not [interned](reader.html#%28tech._interned%29).

If v1 and v2 are [equal?](Equality.html#%28def._%28%28quote._~23~25kernel%29._equal~3f%29%29) but not [eq?](Equality.html#%28def._%28%28quote._~23~25kernel%29._eq~3f%29%29), then it is possible that ([datum-intern-literal](#%28def._%28%28quote._~23~25kernel%29._datum-intern-literal%29%29) v1) will return v1 and—sometime after v1 becomes unreachable as determined by the garbage collector (see [Garbage Collection](eval-model.html#%28part._gc-model%29))—([datum-intern-literal](#%28def._%28%28quote._~23~25kernel%29._datum-intern-literal%29%29) v2) can still return v2. In other words, [datum-intern-literal](#%28def._%28%28quote._~23~25kernel%29._datum-intern-literal%29%29) may adopt a given value as an [interned](reader.html#%28tech._interned%29) representative, but if a former representative becomes otherwise unreachable, then [datum-intern-literal](#%28def._%28%28quote._~23~25kernel%29._datum-intern-literal%29%29) may adopt a new representative.

> ```
(syntax-shift-phase-level stx shift)  →  syntax?
  stx : syntax?
  shift : (or/c exact-integer? #f)
```


# 12.2 Syntax Object Content
Returns a syntax object that is like stx, but with all of its top-level and module bindings shifted by shift phase levels. If shift is #f, then only bindings at phase level 0 are shifted to the label phase level. If shift is 0, then the result is stx.
> ```
(generate-temporaries v)   →   (listof identifier?)
  v : stx-list?```
Returns a list of identifiers that are distinct from all other identifiers. The list contains as many identifiers as v contains elements. The elements of v can be anything, but string, symbol, keyword (possibly wrapped as syntax), and identifier elements will be embedded in the corresponding generated name, which is useful for debugging purposes.
The generated identifiers are built with interned symbols (not [gensym](symbols.html#%28def._%28%28quote._~23~25kernel%29._gensym%29%29)s); see also [Printing Compiled Code](printing.html#%28part._print-compiled%29).
Examples:
> ```racket
> > ( generate-temporaries ' ( a b c d ) )
> '(#<syntax a1> #<syntax b2> #<syntax c3> #<syntax d4>)
> > ( generate-temporaries #' ( 1 2 3 4 ) )
> '(#<syntax temp5> #<syntax temp6> #<syntax temp7> #<syntax temp8>)
> > ( define-syntax ( set!-values stx ) ( syntax-case stx ( ) [ ( _ ( id ... ) expr ) ( with-syntax ( [ ( temp ... ) ( generate-temporaries #' ( id ... ) ) ] ) #' ( let-values ( [ ( temp ... ) expr ] ) ( set! id temp ) ... ( void ) ) ) ] ) )
> ```
> ```
(parameter)	→
(-> listof symbol?)


# 12.2 Syntax Object Content
```
Returns an identifier with the same binding as id-stx, but without possibly lexical information from id-stx that does not apply to the symbols in syms, where even further extension of the lexical information drops information for other symbols. In particular, transferring the lexical context via datum  →  syntax from the result of this function to a symbol other than one in syms may produce an identifier with no binding.

Currently, the result is always id-stx exactly. Pruning was intended primarily as a kind of optimization in a previous version of Racket, but it is less useful and difficult to implement efficiently in the current macro expander.

See also quote-syntax/prune.

Changed in version 6.5 of package base: Always return id-stx.

> ```
(identifier-prune-to-source-module id-stx)   →   identifier?
  id-stx : identifier?```

Returns an identifier with its lexical context minimized to that needed for [syntax-source-module](#%28def._%28%28quote._~23~25kernel%29._syntax-source-module%29%29). The minimized lexical context does not include any bindings.

> ```
(syntax-recertify   new-stx
    old-stx
    inspector
    key)    →    syntax?

  new-stx : syntax?
  old-stx : syntax?
  inspector : inspector?
  key : any/c
```
For backward compatibility only; returns new-stx.
> ```
(syntax-debug-info stx [phase all-bindings?) → hash?
  stx : syntax?
  phase : (or/c exact-integer? #f) = (syntax-local-phase-level)
  all-bindings? : any/c = #f```


# 12.2 Syntax Object Content
Produces a hash table that describes the [lexical information](syntax-model.html#%28tech._lexical._information%29) of stx (not counting components when ([syntax-e](#%28def._%28%28quote._~23~25kernel%29._syntax-e%29%29) stx) would return a compound value). The result can include—but is not limited to—the following keys:
-   'name — the result of ([syntax-e](#%28def._%28%28quote._~23~25kernel%29._syntax-e%29%29) stx), if it is a symbol.
-   'context — a list of vectors, where each vector represents a scope attached to stx.
    Each vector starts with a number that is distinct for every scope. A symbol afterward provides a hint at the scope’s origin: 'module for a [module](module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29) scope, 'macro for a macro-introduction scope, 'use-site for a macro use-site scope, or 'local for a local binding form. In the case of a 'module scope that corresponds to the inside edge, the module’s name and a phase (since an inside-edge scope is generated for each phase) are shown.
-   'bindings — a list of bindings, each represented by a hash table. A binding table can include—but is not limited to—the following keys:
    -   'name — the symbolic name for the binding.
    -   'context — the scopes, as a list of vectors, for the binding.
    -   'local — a symbol representing a [local binding](syntax-model.html#%28tech._local._binding%29); when this key is present, 'module is absent.
    -   'module — an encoding of a import from another module; when this key is present, 'local is absent.


# 12.2 Syntax Object Content
    -   'free-identifier=? — a hash table of debugging information from an identifier for which the binding is an alias.
-   'fallbacks — a list of hash tables like the one produced by [syntax-debug-info](#%28def._%28%28quote._~23~25kernel%29._syntax-debug-info%29%29) for cross-namespace binding fallbacks.
Added in version 6.3 of package base.


#### 12.2.1 Syntax Object Source Locations
|                                                                                |                                                                                |
|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------:|
|  ([require](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) [racket/syntax-srcloc](#%28mod-path._racket%2Fsyntax-srcloc%29)) |  package: [base](https://pkgs.racket-lang.org/package/base "Install this package using `raco pkg install base`") |
The bindings documented in this section are provided by the [racket/syntax-srcloc](#%28mod-path._racket%2Fsyntax-srcloc%29) library, not [racket/base](index.html) or [racket](index.html).
> ```
(syntax-srcloc stx)  →  (or/c #f srcloc?)
  stx : syntax?


# 12.2 Syntax Object Content
```
Returns the source location for the syntax object stx, or #f if none is known.

Added in version 8.2.0.5 of package base.

------------------------------------------------------------------------

# 12.3 Syntax Object Bindings

### 12.3 Syntax Object Bindings

> ```
(bound-identifier=? a-id b-id [phase-level) → boolean?
  a-id : syntax?
  b-id : syntax?
   phase-level   :   (or/c exact-integer? #f)
      =   (syntax-local-phase-level)```

Returns #t if the identifier a-id would bind b-id (or vice versa) if the identifiers were substituted in a suitable expression context at the [phase level](syntax-model.html#%28tech._phase._level%29) indicated by phase-level, #f otherwise. A #f value for phase-level corresponds to the [label phase level](syntax-model.html#%28tech._label._phase._level%29).

Examples:

> ```racket
> > ( define-syntax ( check stx ) ( syntax-case stx ( ) [ ( _ x y ) ( if ( bound-identifier=? #' x #' y ) #' ( let ( [ y ' wrong ] ) ( let ( [ x ' binds ] ) y ) ) #' ( let ( [ y ' no-binds ] ) ( let ( [ x ' wrong ] ) y ) ) ) ] ) )
> > ( check a a )
> 'binds
> > ( check a b )
> 'no-binds
> > ( define-syntax-rule ( check-a x ) ( check a x ) )
> > ( check-a a )
> 'no-binds
> ```

> ```
(free-identifier=? a-id
    b-id
   [ a-phase-level
    b-phase-level)    →    boolean?

  a-id : identifier?
  b-id : identifier?
   a-phase-level   :   (or/c exact-integer? #f)
      =   (syntax-local-phase-level)

  b-phase-level : (or/c exact-integer? #f) = a-phase-level
```


# 12.2 Syntax Object Content
Returns #t if a-id and b-id access the same local binding, module binding, or top-level binding—perhaps via rename transformers—at the phase levels indicated by a-phase-level and b-phase-level, respectively. A #f value for a-phase-level or b-phase-level corresponds to the label phase level.
“Same module binding” means that the identifiers refer to the same original definition site, and not necessarily to the same require or provide site. Due to renaming in require and provide, or due to a transformer binding to a rename transformer, the identifiers may return distinct results with syntax-e.
Examples:
> ```racket
> > ( define-syntax ( check stx ) ( syntax-case stx ( ) [ ( _ x ) ( if ( free-identifier=? #' car #' x ) #' ( list ' same: x ) #' ( list ' different: x ) ) ] ) )
> > ( check car )
> '(same: #<procedure:car>)
> > ( check mcar )
> '(different: #<procedure:mcar>)
> > ( let ( [ car list ] ) ( check car ) )
> '(different: #<procedure:list>)
> > ( require ( rename-in racket/base [ car kar ] ) )
> > ( check kar )
> '(same: #<procedure:car>)
> ```
> ```
(free-transformer-identifier=? a-id b-id) → boolean?
  a-id : identifier?
  b-id : identifier?```
Same as ([free-identifier=?](#%28def._%28%28quote._~23~25kernel%29._free-identifier~3d~3f%29%29) a-id b-id ([add1](generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._add1%29%29) ([syntax-local-phase-level](stxtrans.html#%28def._%28%28quote._~23~25kernel%29._syntax-local-phase-level%29%29)))).
> ```
(free-template-identifier=? a-id b-id) → boolean?
  a-id : identifier?
  b-id : identifier?


# 12.2 Syntax Object Content
```
Same as (free-identifier=? a-id b-id (sub1 (syntax-local-phase-level))).

> ```
(free-label-identifier=? a-id b-id) → boolean?
  a-id : identifier?
  b-id : identifier?```

Same as ([free-identifier=?](#%28def._%28%28quote._~23~25kernel%29._free-identifier~3d~3f%29%29) a-id b-id #f).

> ```
(check-duplicate-identifier ids)  →  (or/c identifier? #f)
  ids : (listof identifier?)
```
(syntax-local-phase-level)	→
(-> or/c ' lexical
    #f
    (list/c module-path-index?
    symbol?
    module-path-index?
    symbol?
    exact-nonnegative-integer?
    phase+space-shift?
    phase+space?)
    (list/c symbol?))```
Returns one of three (if top-level-symbol? is #f) or four (if top-level-symbol? is true) kinds of values, depending on the binding of id-stx at the [phase level](syntax-model.html#%28tech._phase._level%29) indicated by phase-level (where a #f value for phase-level corresponds to the [label phase level](syntax-model.html#%28tech._label._phase._level%29)):
-   The result is 'lexical if id-stx has a [local binding](syntax-model.html#%28tech._local._binding%29).
-   The result is a list of seven items when id-stx has a [module binding](syntax-model.html#%28tech._module._binding%29): ([list](pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29) from-mod from-sym nominal-from-mod nominal-from-sym from-phase import-phase+space-shift nominal-export-phase).


# 12.2 Syntax Object Content
    -   from-mod is a module path index (see [Compiled Modules and References](Module_Names_and_Loading.html#%28part._modpathidx%29)) that indicates the defining module. It is the “self” module path index if the binding refers to a definition in the enclosing module of id-stx.
    -   from-sym is a symbol for the identifier’s name at its definition site in the originating module. This can be different from the local name returned by [syntax->datum](stxops.html#%28def._%28%28quote._~23~25kernel%29._syntax-~3edatum%29%29) for several reasons: the identifier is renamed on import, it is renamed on export, or it is implicitly renamed because the binding site was generated by a macro invocation. In that last case, it may be an [unreadable symbol](symbols.html#%28tech._unreadable._symbol%29), and it may be different from the result of [syntax->datum](stxops.html#%28def._%28%28quote._~23~25kernel%29._syntax-~3edatum%29%29) on the identifier in the original source definition.


# 12.2 Syntax Object Content
    -   nominal-from-mod is a module path index (see [Compiled Modules and References](Module_Names_and_Loading.html#%28part._modpathidx%29)) that indicates the binding’s module as it appears locally in the source around id-stx: it indicates a module [require](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29)d into the context of id-stx to provide its binding, or it is the same “self” as from-mod for a binding that refers to a definition in the enclosing module of id-stx. It can be different from from-mod due to a re-export in nominal-from-mod of some imported identifier. If the same binding is imported in multiple ways, an arbitrary representative is chosen.
    -   nominal-from-sym is a symbol for the binding’s identifier as it appears locally in the source around id-stx: it is the identifier’s name as exported by nominal-from-mod, or it is the source identifier’s symbol for a definition within the enclosing module of id-stx. It can be different from from-sym due to a renaming [provide](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._provide%29%29), even if from-mod and nominal-from-mod are the same, or due to a definition that was introduced by a macro expansion.
    -   from-phase is an exact non-negative integer representing the originating phase. For example, it is 1 if the definition is for-syntax.


# 12.2 Syntax Object Content
    -   import-phase+space-shift is 0 if the binding import of nominal-from-mode is from a definition or a plain [require](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29), 1 if it is from a [for-syntax](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for-syntax%29%29) import, a phase combined with a space name if it is from a [for-space](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for-space%29%29) import, etc.
    -   nominal-export-phase+space is the [phase level](syntax-model.html#%28tech._phase._level%29) and [binding space](syntax-model.html#%28tech._binding._space%29) of the export from nominal-from-mod for an imported binding, or it is the phase level of the definition for a binding from the enclosing module of id-stx.
-   The result is ([list](pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29) top-sym) if id-stx has a [top-level binding](syntax-model.html#%28tech._top._level._binding%29) and top-level-symbol? is true. The top-sym can be different from the name returned by [syntax->datum](stxops.html#%28def._%28%28quote._~23~25kernel%29._syntax-~3edatum%29%29) when the binding definition was generated by a macro invocation.
-   The result is #f if id-stx has a [top-level binding](syntax-model.html#%28tech._top._level._binding%29) and top-level-symbol? is #f or if id-stx is [unbound](syntax-model.html#%28tech._unbound%29). An unbound identifier is typically treated the same as an identifier whose top-level binding is a variable.


# 12.2 Syntax Object Content
If id-stx is bound to a [rename-transformer](syntax-model.html#%28tech._rename._transformer%29), the result from [identifier-binding](#%28def._%28%28quote._~23~25kernel%29._identifier-binding%29%29) is for the identifier in the transformer, so that [identifier-binding](#%28def._%28%28quote._~23~25kernel%29._identifier-binding%29%29) is consistent with [free-identifier=?](#%28def._%28%28quote._~23~25kernel%29._free-identifier~3d~3f%29%29).
If exact-scopes? is a true value, then the result is #f unless the binding for id-stx has exactly the [scopes](syntax-model.html#%28tech._scope%29) of id-stx. An exact-scopes check is useful for detecting whether an identifier is already bound in a specific definition context, for example.
Changed in version 6.6.0.4 of package base: Added the top-level-symbol? argument to report information on top-level bindings.
Changed in version 8.2.0.3: Generalized phase results to phase–space combinations.
Changed in version 8.6.0.9: Added the exact-scopes? argument.
> ```
(syntax-local-phase-level)	→
(-> or/c ' lexical
    #f
    (listof module-path-index?
    symbol?
    module-path-index?
    symbol?
    exact-nonnegative-integer?
    phase+space-shift?
    phase+space?))


# 12.2 Syntax Object Content
```
(parameter)	→
(-> or/c ' lexical
    #f
    (listof module-path-index?
    symbol?
    module-path-index?
    symbol?
    phase+space?
    phase+space-shift?
    phase+space?))```

Same as ([identifier-binding](#%28def._%28%28quote._~23~25kernel%29._identifier-binding%29%29) id-stx ([sub1](generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._sub1%29%29) ([syntax-local-phase-level](stxtrans.html#%28def._%28%28quote._~23~25kernel%29._syntax-local-phase-level%29%29)))).

Changed in version 8.2.0.3 of package base: Generalized phase results to phase–space combinations.

> ```
(parameter)	→
(-> or/c ' lexical
    #f
    (listof module-path-index?
    symbol?
    module-path-index?
    symbol?
    exact-nonnegative-integer?
    phase+space-shift?
    phase+space?))
```
(syntax-local-phase-level)	→
(-> or/c ' lexical
    #f
    (list/c module-path-index?
    symbol?
    module-path-index?
    symbol?
    exact-nonnegative-integer?
    phase+space-shift?
    phase+space?)
    (list/c symbol?))```
Like ([identifier-binding](#%28def._%28%28quote._~23~25kernel%29._identifier-binding%29%29) id-stx phase-level top-level-symbol?), but the result is #f if the binding for id-stx has scopes that are a subset of the scopes for wrt-id-stx. That is, if id-stx and wrt-id-stx have the same symbolic name, a binding for id-stx is returned only if the binding does not also apply to wrt-id-stx.
Added in version 8.3.0.8 of package base.
Changed in version 8.8.0.2: Added the top-level-symbol? argument.
> ```


# 12.2 Syntax Object Content
(syntax-local-phase-level)	→
(-> or/c exact-integer? #f)
```
Like identifier-binding, but produces a symbol that corresponds to the binding. The symbol result is the same for any identifiers that are free-identifier=?, but the result may also be the same for identifiers that are not free-identifier=? (i.e., different symbols imply different bindings, but the same symbol does not imply the same binding).

When identifier-binding would produce a list, then the second element of that list is the result that identifier-binding-symbol produces.

> ```
(identifier-binding-portal-syntax id-stx
   [ phase-level)

   →   (or/c #f syntax?)
  id-stx : identifier?
   phase-level   :   (or/c exact-integer? #f)
      =   (syntax-local-phase-level)```

If id-stx is bound at phase-level to [portal syntax](stxtrans.html#%28tech._portal._syntax%29), either via [define-syntax](define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define-syntax%29%29) or [#%require](require.html#%28form._%28%28quote._~23~25kernel%29._~23~25require%29%29), then the portal syntax content is returned. The module that binds id-stx must be declared, but it need not be instantiated at the relevant phase, and [identifier-binding-portal-syntax](#%28def._%28%28quote._~23~25kernel%29._identifier-binding-portal-syntax%29%29) does not instantiate the module.

Added in version 8.3.0.8 of package base.

> ```
(syntax-local-phase-level)	→
(-> listof symbol?)
```
(syntax-local-phase-level)	→
(-> syntax-local-phase-level)```


# 12.2 Syntax Object Content
Returns a list of sym names of [interned scopes](stxtrans.html#%28tech._interned._scope%29) for which ([identifier-binding](#%28def._%28%28quote._~23~25kernel%29._identifier-binding%29%29) (([make-interned-syntax-introducer](stxtrans.html#%28def._%28%28quote._~23~25kernel%29._make-interned-syntax-introducer%29%29) sym) stx) phase-level #f exact-scopes?) could produce a non-#f value. This procedure takes time proportional to the number of scopes on stx plus the length of the result list.
Added in version 8.13.0.8 of package base.
> ```
(syntax-bound-phases stx)  →  (listof (or/c exact-integer? #f))
  stx : stx?
```
Returns a list that includes all phase-levels for which (syntax-bound-symbols stx phase-level) might produce a non-empty list.

Examples:

> ```racket
> > ( syntax-bound-phases #' anything )
> '(2 1 0)
> > ( require ( for-meta 8 racket/base ) )
> > ( syntax-bound-phases #' anything )
> '(9 8 2 1 0)
> ```

Added in version 8.6.0.8 of package base.

------------------------------------------------------------------------

# 12.4 Syntax Transformers

### 12.4 Syntax Transformers

> ```
(set!-transformer? v)   →   boolean?
  v : any/c```

Returns #t if v is a value created by [make-set!-transformer](#%28def._%28%28quote._~23~25kernel%29._make-set%21-transformer%29%29) or an instance of a structure type with the [prop:set!-transformer](#%28def._%28%28quote._~23~25kernel%29._prop~3aset%21-transformer%29%29) property, #f otherwise.

> ```
(make-set!-transformer proc)  →  set!-transformer?
  proc : (syntax? .  →  . syntax?)
```


# 12.2 Syntax Object Content
Creates an assignment transformer that cooperates with set!. If the result of make-set!-transformer is bound to id as a transformer binding, then proc is applied as a transformer when id is used in an expression position, or when it is used as the target of a set! assignment as (set! id expr). When the identifier appears as a set! target, the entire set! expression is provided to the transformer.
Example:
> ```racket
> > ( let ( [ x 1 ] [ y 2 ] ) ( let-syntax ( [ x ( make-set!-transformer ( lambda ( stx ) ( syntax-case stx ( set! ) ; Redirect mutation of x to y [ ( set! id v ) #' ( set! y v ) ] ; Normal use of x really gets x [ id ( identifier? #' id ) #' x ] ) ) ) ] ) ( begin ( set! x 3 ) ( list x y ) ) ) )
> '(1 3)
> ```
> ```
(set!-transformer-procedure transformer)
   →   (syntax? .  →  . syntax?)
  transformer : set!-transformer?```
Returns the procedure that was passed to [make-set!-transformer](#%28def._%28%28quote._~23~25kernel%29._make-set%21-transformer%29%29) to create transformer or that is identified by the [prop:set!-transformer](#%28def._%28%28quote._~23~25kernel%29._prop~3aset%21-transformer%29%29) property of transformer.
>
<colgroup><col style="width: 100%" /></colgroup>

value

[prop:set!-transformer](#%28def._%28%28quote._~23~25kernel%29._prop~3aset%21-transformer%29%29) : [struct-type-property?](structprops.html#%28def._%28%28quote._~23~25kernel%29._struct-type-property~3f%29%29)


# 12.2 Syntax Object Content
A [structure type property](structprops.html#%28tech._structure._type._property%29) to identify structure types that act as [assignment transformers](syntax-model.html#%28tech._assignment._transformer%29) like the ones created by [make-set!-transformer](#%28def._%28%28quote._~23~25kernel%29._make-set%21-transformer%29%29).
The property value must be an exact integer or procedure of one or two arguments. In the former case, the integer designates a field within the structure that should contain a procedure; the integer must be between 0 (inclusive) and the number of non-automatic fields in the structure type (exclusive, not counting supertype fields), and the designated field must also be specified as immutable.


# 12.2 Syntax Object Content
If the property value is a procedure of one argument, then the procedure serves as a [syntax transformer](syntax-model.html#%28tech._syntax._transformer%29) and for [set!](set_.html#%28form._%28%28quote._~23~25kernel%29._set%21%29%29) transformations. If the property value is a procedure of two arguments, then the first argument is the structure whose type has [prop:set!-transformer](#%28def._%28%28quote._~23~25kernel%29._prop~3aset%21-transformer%29%29) property, and the second argument is a syntax object as for a [syntax transformer](syntax-model.html#%28tech._syntax._transformer%29) and for [set!](set_.html#%28form._%28%28quote._~23~25kernel%29._set%21%29%29) transformations; [set!-transformer-procedure](#%28def._%28%28quote._~23~25kernel%29._set%21-transformer-procedure%29%29) applied to the structure produces a new function that accepts just the syntax object and calls the procedure associated through the property. Finally, if the property value is an integer, the target identifier is extracted from the structure instance; if the field value is not a procedure of one argument, then a procedure that always calls [raise-syntax-error](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._raise-syntax-error%29%29) is used, instead.


# 12.2 Syntax Object Content
If a value has both the [prop:set!-transformer](#%28def._%28%28quote._~23~25kernel%29._prop~3aset%21-transformer%29%29) and [prop:rename-transformer](#%28def._%28%28quote._~23~25kernel%29._prop~3arename-transformer%29%29) properties, then the latter takes precedence. If a structure type has the [prop:set!-transformer](#%28def._%28%28quote._~23~25kernel%29._prop~3aset%21-transformer%29%29) and [prop:procedure](procedures.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._prop~3aprocedure%29%29) properties, then the former takes precedence for the purposes of macro expansion.
> ```
(rename-transformer? v)  →  boolean?
  v : any/c


# 12.2 Syntax Object Content
```
Returns #t if v is a value created by make-rename-transformer or an instance of a structure type with the prop:rename-transformer property, #f otherwise.

Examples:

> ```racket
> > ( rename-transformer? ( make-rename-transformer #' values ) )
> #t
> > ( rename-transformer? ' not-a-rename-transformer )
> #f
> ```

> ```
(make-rename-transformer id-stx)   →   rename-transformer?
  id-stx : syntax?```

Creates a [rename transformer](syntax-model.html#%28tech._rename._transformer%29) that, when used as a [transformer](syntax-model.html#%28tech._transformer%29) binding, acts as a transformer that inserts the identifier id-stx in place of whatever identifier binds the transformer, including in non-application positions, in [set!](set_.html#%28form._%28%28quote._~23~25kernel%29._set%21%29%29) expressions.

Such a transformer could be written manually, but the one created by [make-rename-transformer](#%28def._%28%28quote._~23~25kernel%29._make-rename-transformer%29%29) triggers special cooperation with the parser and other syntactic forms when id is bound to the rename transformer:

-   The parser installs a [free-identifier=?](stxcmp.html#%28def._%28%28quote._~23~25kernel%29._free-identifier~3d~3f%29%29) and [identifier-binding](stxcmp.html#%28def._%28%28quote._~23~25kernel%29._identifier-binding%29%29) equivalence between id and id-stx, as long as id-stx does not have a true value for the 'not-free-identifier=? [syntax property](stxprops.html#%28tech._syntax._property%29).

-   A [provide](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._provide%29%29) of id provides the binding indicated by id-stx instead of id, as long as id-stx does not have a true value for the 'not-free-identifier=? [syntax property](stxprops.html#%28tech._syntax._property%29) and as long as id-stx has a binding.

-   If [provide](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._provide%29%29) exports id, it uses a symbol-valued 'nominal-id property of id-stx to specify the “nominal source identifier” of the binding as reported by [identifier-binding](stxcmp.html#%28def._%28%28quote._~23~25kernel%29._identifier-binding%29%29).

-   If id-stx has a true value for the 'not-provide-all-defined [syntax property](stxprops.html#%28tech._syntax._property%29), then id (or its target) is not exported by [all-defined-out](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._all-defined-out%29%29).

-   The [syntax-local-value](#%28def._%28%28quote._~23~25kernel%29._syntax-local-value%29%29) function recognizes rename-transformer bindings and consult their targets.

Examples:

> ```racket
> > ( define-syntax my-or ( make-rename-transformer #' or ) )
> > ( my-or #f #t )
> #t
> > ( free-identifier=? #' my-or #' or )
> #t
> ```

Changed in version 6.3 of package base: Removed an optional second argument.
Changed in version 7.4.0.10: Adjusted rename-transformer expansion to add a macro-introduction scope, the same as regular macro expansion.

> ```
(rename-transformer-target transformer)  →  identifier?
  transformer : rename-transformer?
```


# 12.2 Syntax Object Content
Returns the identifier passed to make-rename-transformer to create transformer or as indicated by a prop:rename-transformer property on transformer.
Example:
> ```racket
> > ( rename-transformer-target ( make-rename-transformer #' or ) )
> #<syntax:eval:8:0 or>
> ```
>
<colgroup><col style="width: 100%" /></colgroup>

value

prop:rename-transformer : struct-type-property?

A structure type property to identify structure types that act as rename transformers like the ones created by make-rename-transformer.
The property value must be an exact integer, an identifier syntax object, or a procedure that takes one argument. In the former case, the integer designates a field within the structure that should contain an identifier; the integer must be between 0 (inclusive) and the number of non-automatic fields in the structure type (exclusive, not counting supertype fields), and the designated field must also be specified as immutable.
If the property value is an identifier, the identifier serves as the target for renaming, just like the first argument to make-rename-transformer. If the property value is an integer, the target identifier is extracted from the structure instance; if the field value is not an identifier, then an identifier ? with an empty context is used, instead.


# 12.2 Syntax Object Content
If the property value is a procedure that takes one argument, then the procedure is called to obtain the identifier that the rename transformer will use as a target identifier. The returned identifier should probably have the 'not-free-identifier=? syntax property. If the procedure returns any value that is not an identifier, the exn:fail:contract exception is raised.
Examples:
> ```racket
> ; Example of a procedure argument for prop:rename-transformer
> > ( define-syntax slv-1 ' first-transformer-binding )
> > ( define-syntax slv-2 ' second-transformer-binding )
> > ( begin-for-syntax ( struct slv-cooperator ( redirect-to-first? ) #:property prop:rename-transformer ( λ ( inst ) ( if ( slv-cooperator-redirect-to-first? inst ) #' slv-1 #' slv-2 ) ) ) )
> > ( define-syntax ( slv-lookup stx ) ( syntax-case stx ( ) [ ( _ id ) #` ' #, ( syntax-local-value #' id ) ] ) )
> > ( define-syntax slv-inst-1 ( slv-cooperator #t ) )
> > ( define-syntax slv-inst-2 ( slv-cooperator #f ) )
> > ( slv-lookup slv-inst-1 )
> 'first-transformer-binding
> > ( slv-lookup slv-inst-2 )
> 'second-transformer-binding
> ```
Changed in version 6.3 of package base: the property now accepts a procedure of one argument.
> ```
(local-expand stx
    context-v
    stop-ids
   [ intdef-ctx)    →    syntax?
  stx : any/c
  context-v : (or/c 'expression 'top-level 'module 'module-begin list?)
  stop-ids : (or/c (listof identifier?) empty #f)
   intdef-ctx   :   ( or/c internal-definition-context?
> #f
> ( listof internal-definition-context? ) )   =   #f```


# 12.2 Syntax Object Content
Expands stx in the lexical context of the expression currently being expanded. The context-v argument is used as the result of [syntax-local-context](#%28def._%28%28quote._~23~25kernel%29._syntax-local-context%29%29) for immediate expansions; a list indicates an [internal-definition context](syntax-model.html#%28tech._internal._definition._context%29), and more information on the form of the list is below. If stx is not already a [syntax object](syntax-model.html#%28tech._syntax._object%29), it is coerced with ([datum->syntax](stxops.html#%28def._%28%28quote._~23~25kernel%29._datum-~3esyntax%29%29) #f stx) before expansion.
The stop-ids argument controls how far [local-expand](#%28def._%28%28quote._~23~25kernel%29._local-expand%29%29) expands stx:
-   If stop-ids is an empty list, then stx is recursively expanded (i.e. expansion proceeds to sub-expressions). The result is guaranteed to be a fully-expanded form, which can include the bindings listed in [Fully Expanded Programs](syntax-model.html#%28part._fully-expanded%29), plus [#%expression](__expression.html#%28form._%28%28quote._~23~25kernel%29._~23~25expression%29%29) in any expression position.


# 12.2 Syntax Object Content
-   If stop-ids is a list containing just [module*](module.html#%28form._%28%28quote._~23~25kernel%29._module%2A%29%29), then expansion proceeds as if stop-ids were an empty list, except that expansion does not recur to [submodules](eval-model.html#%28tech._submodule%29) defined with [module*](module.html#%28form._%28%28quote._~23~25kernel%29._module%2A%29%29) (which are left unexpanded in the result).
-   If stop-ids is any other list, then [begin](begin.html#%28form._%28%28quote._~23~25kernel%29._begin%29%29), [quote](quote.html#%28form._%28%28quote._~23~25kernel%29._quote%29%29), [set!](set_.html#%28form._%28%28quote._~23~25kernel%29._set%21%29%29), [#%plain-lambda](lambda.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~23~25plain-lambda%29%29), [case-lambda](lambda.html#%28form._%28%28quote._~23~25kernel%29._case-lambda%29%29), [let-values](let.html#%28form._%28%28quote._~23~25kernel%29._let-values%29%29), [letrec-values](let.html#%28form._%28%28quote._~23~25kernel%29._letrec-values%29%29), [if](if.html#%28form._%28%28quote._~23~25kernel%29._if%29%29), [begin0](begin.html#%28form._%28%28quote._~23~25kernel%29._begin0%29%29), [with-continuation-mark](wcm.html#%28form._%28%28quote._~23~25kernel%29._with-continuation-mark%29%29), [letrec-syntaxes+values](let.html#%28form._%28%28quote._~23~25kernel%29._letrec-syntaxes%2Bvalues%29%29), [#%plain-app](application.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~23~25plain-app%29%29), [#%expression](__expression.html#%28form._%28%28quote._~23~25kernel%29._~23~25expression%29%29), [#%top](__top.html#%28form._%28%28quote._~23~25kernel%29._~23~25top%29%29), and [#%variable-reference](Locations____variable-reference.html#%28form._%28%28quote._~23~25kernel%29._~23~25variable-reference%29%29) are implicitly added to stop-ids. Expansion proceeds recursively, stopping when the expander encounters any of the forms in stop-ids, and the result is the partially-expanded form.


# 12.2 Syntax Object Content
    When the expander would normally implicitly introduce a #%app, #%datum, or #%top identifier as described in [Expansion Steps](syntax-model.html#%28part._expand-steps%29), it checks to see if an identifier with the same [binding](syntax-model.html#%28tech._binding%29) as the one to be introduced appears in stop-ids. If so, the identifier is not introduced; the result of expansion is the bare application, literal data expression, or unbound identifier rather than one wrapped in the respective explicit form.
    When [#%plain-module-begin](module.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~23~25plain-module-begin%29%29) is not in stop-ids, the [#%plain-module-begin](module.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~23~25plain-module-begin%29%29) transformer detects and expands sub-forms (such as [define-values](define.html#%28form._%28%28quote._~23~25kernel%29._define-values%29%29)) regardless of the identifiers presence in stop-ids.
    Expansion does not replace the scopes in a local-variable reference to match the binding identifier.
-   If stop-ids is #f instead of a list, then stx is expanded only as long as the outermost form of stx is a macro (i.e. expansion does not proceed to sub-expressions, and it does not replace the scopes in a local-variable reference to match the binding identifier). The #%app, #%datum, and #%top identifiers are never introduced.


# 12.2 Syntax Object Content
Independent of stop-ids, when [local-expand](#%28def._%28%28quote._~23~25kernel%29._local-expand%29%29) encounters an identifier that has a local binding but no binding in the current expansion context, the variable is left as-is (as opposed to triggering an “out of context” syntax error).
When context-v is 'module-begin, and the result of expansion is a [#%plain-module-begin](module.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~23~25plain-module-begin%29%29) form, then a 'submodule [syntax property](stxprops.html#%28tech._syntax._property%29) is added to each enclosed [module](module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29) form (but not [module*](module.html#%28form._%28%28quote._~23~25kernel%29._module%2A%29%29) forms) in the same way as by [module](module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29) expansion.


# 12.2 Syntax Object Content
If the intdef-ctx argument is an internal-definition context, its [bindings](syntax-model.html#%28tech._binding%29) and [bindings](syntax-model.html#%28tech._binding%29) from all [parent internal-definition contexts](#%28tech._parent._internal._definition._context%29) are added to the [local binding context](syntax-model.html#%28tech._local._binding._context%29) during the dynamic extent of the call to [local-expand](#%28def._%28%28quote._~23~25kernel%29._local-expand%29%29). Additionally, unless #f was provided for the add-scope? argument to [syntax-local-make-definition-context](#%28def._%28%28quote._~23~25kernel%29._syntax-local-make-definition-context%29%29) when the internal-definition context was created, its [inside-edge scope](syntax-model.html#%28tech._inside._edge._scope%29) (but not the scopes of any [parent internal-definition contexts](#%28tech._parent._internal._definition._context%29)) is added to the [lexical information](syntax-model.html#%28tech._lexical._information%29) for both stx prior to its expansion and the expansion result (because the expansion might introduce bindings or references to internal-definition bindings).


# 12.2 Syntax Object Content
For backwards compatibility, when intdef-ctx is a list all [bindings](syntax-model.html#%28tech._binding%29) from all of the provided internal-definition contexts and their parents are added to the [local binding context](syntax-model.html#%28tech._local._binding._context%29), and the [inside-edge scope](syntax-model.html#%28tech._inside._edge._scope%29) from each context for which add-scope? was not #f is added in the same way.
Expansion records [use-site scopes](syntax-model.html#%28tech._use._site._scope%29) for removal from definition bindings. When the intdef-ctx argument is an internal-definition context, use-site scopes are recorded with that context. When intdef-ctx is #f or (for backwards compatibility) a list, use-site scopes are recorded with the current expand context.


# 12.2 Syntax Object Content
For a particular [internal-definition context](syntax-model.html#%28tech._internal._definition._context%29), generate a unique value and put it into a list for context-v. To allow [liberal expansion](#%28tech._liberal._expansion%29) of [define](define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29) forms, the generated value should be an instance of a structure with a true value for [prop:liberal-define-context](#%28def._%28%28quote._~23~25kernel%29._prop~3aliberal-define-context%29%29). If the internal-definition context is meant to be self-contained, the list for context-v should contain only the generated value; if the internal-definition context is meant to splice into an immediately enclosing context, then when [syntax-local-context](#%28def._%28%28quote._~23~25kernel%29._syntax-local-context%29%29) produces a list, [cons](pairs.html#%28def._%28%28quote._~23~25kernel%29._cons%29%29) the generated value onto that list.


# 12.2 Syntax Object Content
When expressions are expanded via [local-expand](#%28def._%28%28quote._~23~25kernel%29._local-expand%29%29) with an internal-definition context intdef-ctx, and when the expanded expressions are incorporated into an overall form new-stx, then typically [internal-definition-context-track](https://plt.cs.northwestern.edu/new-snapshots/new-snapshots/doc/local-redirect/index.html?doc=syntax&rel=intdef.html%23%2528def._%2528%2528lib._syntax%252Fintdef..rkt%2529._internal-definition-context-track%2529%2529&version=8.18.0.13) should be applied to intdef-ctx and new-stx to provide expansion history to external tools.
This procedure must be called during the dynamic extent of a [syntax transformer](syntax-model.html#%28tech._syntax._transformer%29) application by the expander or while a module is [visit](syntax-model.html#%28tech._visit%29)ed (see [syntax-transforming?](#%28def._%28%28quote._~23~25kernel%29._syntax-transforming~3f%29%29)), otherwise the [exn:fail:contract](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29) exception is raised.
Examples:


# 12.2 Syntax Object Content
> ```racket
> > ( define-syntax-rule ( do-print x ... ) ( printf x ... ) )
> > ( define-syntax-rule ( hello x ) ( do-print "hello ~a" x ) )
> > ( define-syntax ( show stx ) ( syntax-case stx ( ) [ ( _ x ) ( let ( [ partly ( local-expand #' ( hello x ) ' expression ( list #' do-print ) ) ] [ fully ( local-expand #' ( hello x ) ' expression #f ) ] ) ( printf "partly expanded: ~s\n" ( syntax->datum partly ) ) ( printf "fully expanded: ~s\n" ( syntax->datum fully ) ) fully ) ] ) )
> > ( show 1 )
> partly expanded: (do-print "hello ~a" 1) fully expanded: (printf "hello ~a" 1) hello 1
> ```
This procedure’s binding is provided as [protected](modprotect.html#%28tech._protected%29) in the sense of [protect-out](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._protect-out%29%29).
Changed in version 6.0.1.3 of package base: Changed treatment of [#%top](__top.html#%28form._%28%28quote._~23~25kernel%29._~23~25top%29%29) so that it is never introduced as an explicit wrapper.
Changed in version 6.0.90.27: Loosened the contract on the intdef-ctx argument to allow an empty list.
Changed in version 8.2.0.4: Changed binding to [protected](modprotect.html#%28tech._protected%29).
> ```
(syntax-local-expand-expression stx
   [ opaque-only?)
   →    (if opaque-only? #f syntax?)   syntax?
  stx : any/c
  opaque-only? : any/c = #f


# 12.2 Syntax Object Content
```
Like local-expand given 'expression and an empty stop list, but with two results: a syntax object for the fully expanded expression, and a syntax object whose content is opaque.

The latter can be used in place of the former (perhaps in a larger expression produced by a macro transformer), and when the macro expander encounters the opaque object, it substitutes the fully expanded expression without re-expanding it; the exn:fail:syntax exception is raised if the expansion context includes scopes that were not present for the original expansion, in which case re-expansion might produce different results. Consistent use of syntax-local-expand-expression and the opaque object thus avoids quadratic expansion times when local expansions are nested.

If opaque-only? is true, then the first result is #f instead of the expanded expression. Obtaining only the second, opaque result can be more efficient in some expansion contexts.

Unlike local-expand, syntax-local-expand-expression normally produces an expanded expression that contains no #%expression forms. However, if syntax-local-expand-expression is used within an expansion that is triggered by an enclosing local-expand call, then the result of syntax-local-expand-expression can include #%expression forms.

This procedure must be called during the dynamic extent of a syntax transformer application by the expander or while a module is visited (see syntax-transforming?), otherwise the exn:fail:contract exception is raised.

This procedure’s binding is provided as protected in the sense of protect-out.

Changed in version 6.90.0.13 of package base: Added the opaque-only? argument.
Changed in version 8.2.0.4: Changed binding to protected.

> ```
(local-transformer-expand stx
    context-v
    stop-ids
   [ intdef-ctx)    →    syntax?

  stx : any/c
  context-v : (or/c 'expression 'top-level list?)
  stop-ids : (or/c (listof identifier?) #f)
   intdef-ctx   :   ( or/c internal-definition-context?
> #f
> ( listof internal-definition-context? ) )   =   #f```

Like [local-expand](#%28def._%28%28quote._~23~25kernel%29._local-expand%29%29), but stx is expanded as a transformer expression instead of a run-time expression.

Any lifted expressions—from calls to [syntax-local-lift-expression](#%28def._%28%28quote._~23~25kernel%29._syntax-local-lift-expression%29%29) during the expansion of stx—are captured in the result. If context-v is 'top-level, then lifts are captured in a [begin](begin.html#%28form._%28%28quote._~23~25kernel%29._begin%29%29) form, otherwise lifts are captured in [let-values](let.html#%28form._%28%28quote._~23~25kernel%29._let-values%29%29) forms. If no expressions are lifted during expansion, then no [begin](begin.html#%28form._%28%28quote._~23~25kernel%29._begin%29%29) or [let-values](let.html#%28form._%28%28quote._~23~25kernel%29._let-values%29%29) wrapper is added.

This procedure’s binding is provided as [protected](modprotect.html#%28tech._protected%29) in the sense of [protect-out](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._protect-out%29%29).

Changed in version 6.5.0.3 of package base: Allowed and captured lifts in a 'top-level context.
Changed in version 8.2.0.4: Changed binding to [protected](modprotect.html#%28tech._protected%29).

> ```
(local-expand/capture-lifts stx
    context-v
    stop-ids
   [ intdef-ctx
    lift-ctx)    →    syntax?

  stx : any/c
  context-v : (or/c 'expression 'top-level 'module 'module-begin list?)
  stop-ids : (or/c (listof identifier?) #f)
   intdef-ctx   :   ( or/c internal-definition-context?
> #f
> ( listof internal-definition-context? ) )   =   #f

  lift-ctx : any/c = (gensym 'lifts)
```


# 12.2 Syntax Object Content
Like local-expand, but the result is a syntax object that represents a begin expression. Lifted expressions—from calls to syntax-local-lift-expression during the expansion of stx—appear with their identifiers in define-values forms, and the expansion of stx is the last expression in the begin. The lift-ctx value is reported by syntax-local-lift-context during local expansion. The lifted expressions are not expanded, but instead left as provided in the begin form.
If context-v is 'top-level or 'module, then module forms can appear in the result as added via syntax-local-lift-module. If context-v is 'module, then module* forms can appear, too.
This procedure’s binding is provided as protected in the sense of protect-out.
Changed in version 8.2.0.4 of package base: Changed binding to protected.
> ```
(local-transformer-expand/capture-lifts stx
    context-v
    stop-ids
   [ intdef-ctx
    lift-ctx)    →    syntax?
  stx : any/c
  context-v : (or/c 'expression 'top-level list?)
  stop-ids : (or/c (listof identifier?) #f)
   intdef-ctx   :   ( or/c internal-definition-context?
> #f
> ( listof internal-definition-context? ) )   =   #f
  lift-ctx : any/c = (gensym 'lifts)```
Like [local-expand/capture-lifts](#%28def._%28%28quote._~23~25kernel%29._local-expand%2Fcapture-lifts%29%29), but stx is expanded as a transformer expression instead of a run-time expression. Lifted expressions are reported as [define-values](define.html#%28form._%28%28quote._~23~25kernel%29._define-values%29%29) forms (in the transformer environment).


# 12.2 Syntax Object Content
This procedure’s binding is provided as [protected](modprotect.html#%28tech._protected%29) in the sense of [protect-out](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._protect-out%29%29).
Changed in version 8.2.0.4 of package base: Changed binding to [protected](modprotect.html#%28tech._protected%29).
> ```
(syntax-local-apply-transformer transformer
    binding-id
    context-v
    intdef-ctx
    v ...)    →    any
  transformer : procedure?
  binding-id : (or/c identifier? #f)
  context-v : (or/c 'expression 'top-level 'module 'module-begin list?)
  intdef-ctx : (or/c internal-definition-context? #f)
  v : any/c


# 12.2 Syntax Object Content
```
Applies the procedure transformer to the vs in a new expansion context and local binding context. Adds and flips macro-introduction scopes and use-site scopes on the arguments and return values in the same manner as syntax transformer application. The arguments and returns may be any value; scopes are manipulated only for those that are syntax objects.

The context-v argument is as in local-expand, and the intdef-ctx is an internal-definition context value or #f. The binding-id specifies a binding associated with the transformer, which the expander uses to determine whether to add use-site scopes and which code inspector to use during expansion.

This procedure must be called during the dynamic extent of a syntax transformer application by the expander or while a module is visited (see syntax-transforming?), otherwise the exn:fail:contract exception is raised.

Added in version 8.2.0.7 of package base.

> ```
(internal-definition-context? v)   →   boolean?
  v : any/c```

Returns #t if v is an [internal-definition context](syntax-model.html#%28tech._internal._definition._context%29), #f otherwise.

> ```
(syntax-local-make-definition-context [parent-ctx
    add-scope?)

  →  internal-definition-context?
  parent-ctx : (or/c internal-definition-context? #f) = #f
  add-scope? : any/c = #t
```
(partial)	→
(-> (syntax?) ((or/c 'flip 'add 'remove)) . → * . syntax?)```


# 12.2 Syntax Object Content
Like [make-syntax-introducer](#%28def._%28%28quote._~23~25kernel%29._make-syntax-introducer%29%29), but the encapsulated [scope](syntax-model.html#%28tech._scope%29) is pruned from [quote-syntax](Syntax_Quoting__quote-syntax.html#%28form._%28%28quote._~23~25kernel%29._quote-syntax%29%29) forms, much like the scopes associated with a new definition context (see [syntax-local-make-definition-context](#%28def._%28%28quote._~23~25kernel%29._syntax-local-make-definition-context%29%29)). The name argument is used as the symbolic name, which serves as a debugging aid.
Typically, [internal-definition-context-add-scopes](#%28def._%28%28quote._~23~25kernel%29._internal-definition-context-add-scopes%29%29) and [internal-definition-context-splice-binding-identifier](#%28def._%28%28quote._~23~25kernel%29._internal-definition-context-splice-binding-identifier%29%29) are preferred, but this function can be useful when you are sure that you want a single scope that should be pruned from [quote-syntax](Syntax_Quoting__quote-syntax.html#%28form._%28%28quote._~23~25kernel%29._quote-syntax%29%29) forms.


# 12.2 Syntax Object Content
This procedure must be called during the dynamic extent of a [syntax transformer](syntax-model.html#%28tech._syntax._transformer%29) application by the expander or while a module is [visit](syntax-model.html#%28tech._visit%29)ed (see [syntax-transforming?](#%28def._%28%28quote._~23~25kernel%29._syntax-transforming~3f%29%29)), otherwise the [exn:fail:contract](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29) exception is raised.
Added in version 8.12.0.8 of package base.
> ```
(internal-definition-context-add-scopes   intdef-ctx
    stx)    →    syntax?
  intdef-ctx : internal-definition-context?
  stx : syntax?


# 12.2 Syntax Object Content
```
Adds the outside-edge scope and inside-edge scope for intdef-ctx to stx.

Use this function to apply the definition context scopes to syntax that originates within the definition context before expansion.

Added in version 8.2.0.7 of package base.

> ```
(internal-definition-context-splice-binding-identifier
    intdef-ctx
    id)

   →   syntax?
  intdef-ctx : internal-definition-context?
  id : identifier?```

Removes scopes associated with the intdef-ctx from id: the [outside-edge scope](syntax-model.html#%28tech._outside._edge._scope%29), the [inside-edge scope](syntax-model.html#%28tech._inside._edge._scope%29), and [use-site scopes](syntax-model.html#%28tech._use._site._scope%29) created by expansions within the definition context.

Use when splicing a binding originating within the intdef-ctx into a surrounding context.

Added in version 8.2.0.7 of package base.

> ```
(syntax-local-bind-syntaxes id-list
    expr
    intdef-ctx
   [ extra-intdef-ctxs)

  →  (listof identifier?)
  id-list : (listof identifier?)
  expr : (or/c syntax? #f)
  intdef-ctx : internal-definition-context?
   extra-intdef-ctxs   :   ( or/c internal-definition-context?
> ( listof internal-definition-context? ) )
      =   '()
```
Binds each identifier in id-list within the internal-definition context represented by intdef-ctx, where intdef-ctx is the result of syntax-local-make-definition-context. Returns identifiers with lexical information matching the new bindings.


# 12.2 Syntax Object Content
For backwards compatibility, the lexical information of each element of extra-intdef-ctxs is also added to each identifier in id-list before binding.
Supply #f for expr when the identifiers correspond to define-values bindings, and supply a compile-time expression when the identifiers correspond to define-syntaxes bindings. In the latter case, the number of values produced by the expression should match the number of identifiers, otherwise the exn:fail:contract:arity exception is raised.
When expr is not #f, it is expanded in an expression context and evaluated in the current transformer environment. In this case, the bindings and lexical information from both intdef-ctx and extra-intdef-ctxs are used to enrich expr’s lexical information and extend the local binding context in the same way as the fourth argument to local-expand. If expr is #f, the value provided for extra-intdef-ctxs is ignored.
This procedure must be called during the dynamic extent of a syntax transformer application by the expander or while a module is visited (see syntax-transforming?), otherwise the exn:fail:contract exception is raised.
Changed in version 6.90.0.27 of package base: Added the extra-intdef-ctxs argument.
Changed in version 8.2.0.7: Changed the return value from #<void> to the list of bound identifiers.
> ```
(internal-definition-context-binding-identifiers intdef-ctx)
   →   (listof identifier?)
  intdef-ctx : internal-definition-context?```


# 12.2 Syntax Object Content
Returns a list of all binding identifiers registered for intdef-ctx through [syntax-local-bind-syntaxes](#%28def._%28%28quote._~23~25kernel%29._syntax-local-bind-syntaxes%29%29). Each identifier in the returned list includes the [internal-definition context](syntax-model.html#%28tech._internal._definition._context%29)’s [scope](syntax-model.html#%28tech._scope%29).
Added in version 6.3.0.4 of package base.
> ```
(internal-definition-context-introduce intdef-ctx
    stx
   [ mode)    →    syntax?
  intdef-ctx : internal-definition-context?
  stx : syntax?
  mode : (or/c 'flip 'add 'remove) = 'flip
```
(parameter)	→```

For backward compatibility only; has no effect.

> ```
(identifier-remove-from-definition-context   id-stx
    intdef-ctx)

  →  identifier?
  id-stx : identifier?
   intdef-ctx   :   ( or/c internal-definition-context?
> ( listof internal-definition-context? ) )
```
Removes all of the scopes of intdef-ctx (or of each element in a list intdef-ctx) from id-stx.
The identifier-remove-from-definition-context function is provided for backward compatibility; the internal-definition-context-splice-binding-identifier function is preferred.
Changed in version 6.3 of package base: Simplified the operation to scope removal.
>
<colgroup><col style="width: 100%" /></colgroup>

value

prop:expansion-contexts : struct-type-property?


# 12.2 Syntax Object Content
A structure type property to constrain the use of macro transformers and rename transformers. The property’s value must be a list of symbols, where the allowed symbols are 'expression, 'top-level, 'module, 'module-begin, and 'definition-context. Each symbol corresponds to an expansion context in the same way as for local-expand or as reported by syntax-local-context, except that 'definition-context is used (instead of a list) to represent an internal-definition context.
If an identifier is bound to a transformer whose list does not include a symbol for a particular use of the identifier, then the use is adjusted as follows:
-  In a 'module-begin context, then the use is wrapped in a begin form.
-  In a 'module, 'top-level, 'internal-definition or context, if 'expression is present in the list, then the use is wrapped in an #%expression form.
-  Otherwise, a syntax error is reported.
The prop:expansion-contexts property is most useful in combination with prop:rename-transformer, since a general transformer procedure can use syntax-local-context. Furthermore, a prop:expansion-contexts property makes the most sense when a rename transformer’s identifier has the 'not-free-identifier=? property, otherwise a definition of the binding creates a binding alias that effectively routes around the prop:expansion-contexts property.
Added in version 6.3 of package base.
> ```
(syntax-local-value id-stx
   [ failure-thunk
    intdef-ctx)    →    any


# 12.2 Syntax Object Content
  id-stx : identifier?
  failure-thunk : (or/c (  →   any) #f) = #f
   intdef-ctx   :   ( or/c internal-definition-context?
> #f
> ( listof internal-definition-context? ) )   =   #f```
Returns the [transformer](syntax-model.html#%28tech._transformer%29) binding value of the identifier id-stx in the context of the current expansion. If intdef-ctx is not #f, bindings from all provided definition contexts are also considered. Unlike the fourth argument to [local-expand](#%28def._%28%28quote._~23~25kernel%29._local-expand%29%29), the [scopes](syntax-model.html#%28tech._scope%29) associated with the provided definition contexts are not used to enrich id-stx’s [lexical information](syntax-model.html#%28tech._lexical._information%29).
If id-stx is bound to a [rename transformer](syntax-model.html#%28tech._rename._transformer%29) created with [make-rename-transformer](#%28def._%28%28quote._~23~25kernel%29._make-rename-transformer%29%29), [syntax-local-value](#%28def._%28%28quote._~23~25kernel%29._syntax-local-value%29%29) effectively calls itself with the target of the rename and returns that result, instead of the [rename transformer](syntax-model.html#%28tech._rename._transformer%29).


# 12.2 Syntax Object Content
If id-stx has no [transformer](syntax-model.html#%28tech._transformer%29) binding (via [define-syntax](define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define-syntax%29%29), [let-syntax](let.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._let-syntax%29%29), etc.) in that environment, the result is obtained by applying failure-thunk if not #f. If failure-thunk is [false](booleans.html#%28def._%28%28lib._racket%2Fbool..rkt%29._false%29%29), the [exn:fail:contract](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29) exception is raised.
This procedure must be called during the dynamic extent of a [syntax transformer](syntax-model.html#%28tech._syntax._transformer%29) application by the expander or while a module is [visit](syntax-model.html#%28tech._visit%29)ed (see [syntax-transforming?](#%28def._%28%28quote._~23~25kernel%29._syntax-transforming~3f%29%29)), otherwise the [exn:fail:contract](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29) exception is raised.
Examples:
> ```racket
> > ( define-syntax swiss-cheeses? #t )
> > ( define-syntax ( transformer stx ) ( if ( syntax-local-value #' swiss-cheeses? ) #' ' ( gruyère emmental raclette ) #' ' ( roquefort camembert boursin ) ) )
> > ( transformer )
> '(gruyère emmental raclette)
> ```
Examples:
> ```racket
> > ( define-syntax ( transformer-2 stx ) ( syntax-local-value #' something-else ( λ ( ) ( error "no binding" ) ) ) )
> > ( transformer-2 )
> no binding
> ```
Examples:


# 12.2 Syntax Object Content
> ```racket
> > ( define-syntax nachos #' ( printf "nachos~n" ) )
> > ( define-syntax chips ( make-rename-transformer #' nachos ) )
> > ( define-syntax ( transformer-3 stx ) ( syntax-local-value #' chips ) )
> > ( transformer-3 )
> nachos
> ```
This procedure’s binding is provided as [protected](modprotect.html#%28tech._protected%29) in the sense of [protect-out](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._protect-out%29%29).
Changed in version 6.90.0.27 of package base: Changed intdef-ctx to accept a list of internal-definition contexts in addition to a single internal-definition context or #f.
Changed in version 8.2.0.4: Changed binding to [protected](modprotect.html#%28tech._protected%29).
> ```
(syntax-local-value/immediate id-stx
   [ failure-thunk
    intdef-ctx)    →    any
  id-stx : syntax?
  failure-thunk : (or/c (  →   any) #f) = #f
   intdef-ctx   :   ( or/c internal-definition-context?
> #f
> ( listof internal-definition-context? ) )   =   #f


# 12.2 Syntax Object Content
```
Like syntax-local-value, but the result is normally two values. If id-stx is bound to a rename transformer, the results are the rename transformer and the identifier in the transformer. Beware that provide on an id bound to a rename transformer may export the target of the rename instead of id. See make-rename-transformer for more information. If id-stx is not bound to a rename transformer, then the results are the value that syntax-local-value would produce and #f.

If id-stx has no transformer binding, then failure-thunk is called (and it can return any number of values), or an exception is raised if failure-thunk is #f.

Examples:

> ```racket
> > ( define-syntax agent-007 ( make-rename-transformer #' james-bond ) )
> > ( define-syntax ( show-secret-identity stx ) ( syntax-parse stx [ ( _ name:id ) ( define-values [ _ orig-name ] ( syntax-local-value/immediate #' name ) ) #` ' ( name #, orig-name ) ] ) )
> > ( show-secret-identity agent-007 )
> '(agent-007 james-bond)
> ```

This procedure’s binding is provided as protected in the sense of protect-out.

Changed in version 8.2.0.4 of package base: Changed binding to protected.

> ```
(syntax-local-lift-expression stx) → identifier?
  stx : syntax?```

Returns a fresh identifier, and cooperates with the [module](module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29), [letrec-syntaxes+values](let.html#%28form._%28%28quote._~23~25kernel%29._letrec-syntaxes%2Bvalues%29%29), [define-syntaxes](define.html#%28form._%28%28quote._~23~25kernel%29._define-syntaxes%29%29), [begin-for-syntax](begin.html#%28form._%28%28quote._~23~25kernel%29._begin-for-syntax%29%29), and top-level expanders to bind the generated identifier to the expression stx.

A run-time expression within a module is lifted to the module’s top level, just before the expression whose expansion requests the lift. Similarly, a run-time expression outside of a module is lifted to a top-level definition. A compile-time expression in a [letrec-syntaxes+values](let.html#%28form._%28%28quote._~23~25kernel%29._letrec-syntaxes%2Bvalues%29%29) or [define-syntaxes](define.html#%28form._%28%28quote._~23~25kernel%29._define-syntaxes%29%29) binding is lifted to a [let](let.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._let%29%29) wrapper around the corresponding right-hand side of the binding. A compile-time expression within [begin-for-syntax](begin.html#%28form._%28%28quote._~23~25kernel%29._begin-for-syntax%29%29) is lifted to a [define](define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29) declaration just before the requesting expression within the [begin-for-syntax](begin.html#%28form._%28%28quote._~23~25kernel%29._begin-for-syntax%29%29).

Other syntactic forms can capture lifts by using [local-expand/capture-lifts](#%28def._%28%28quote._~23~25kernel%29._local-expand%2Fcapture-lifts%29%29) or [local-transformer-expand/capture-lifts](#%28def._%28%28quote._~23~25kernel%29._local-transformer-expand%2Fcapture-lifts%29%29).

This procedure must be called during the dynamic extent of a [syntax transformer](syntax-model.html#%28tech._syntax._transformer%29) application by the expander or while a module is [visit](syntax-model.html#%28tech._visit%29)ed (see [syntax-transforming?](#%28def._%28%28quote._~23~25kernel%29._syntax-transforming~3f%29%29)), otherwise the [exn:fail:contract](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29) exception is raised.

In addition, this procedure can be called only when a lift target is available, as indicated by [syntax-transforming-with-lifts?](#%28def._%28%28quote._~23~25kernel%29._syntax-transforming-with-lifts~3f%29%29).

> ```
(syntax-local-lift-values-expression n stx)
  →  (listof identifier?)
  n : exact-nonnegative-integer?
  stx : syntax?
```


# 12.2 Syntax Object Content
Like syntax-local-lift-expression, but binds the result to n identifiers, and returns a list of the n identifiers.
This procedure must be called during the dynamic extent of a syntax transformer application by the expander or while a module is visited (see syntax-transforming?), otherwise the exn:fail:contract exception is raised.
> ```
(syntax-local-lift-context)   →   any/c```
Returns a value that represents the target for expressions lifted via [syntax-local-lift-expression](#%28def._%28%28quote._~23~25kernel%29._syntax-local-lift-expression%29%29). That is, for different transformer calls for which this procedure returns the same value (as determined by [eq?](Equality.html#%28def._%28%28quote._~23~25kernel%29._eq~3f%29%29)), lifted expressions for the two transformer are moved to the same place. Thus, the result is useful for caching lift information to avoid redundant lifts.
This procedure must be called during the dynamic extent of a [syntax transformer](syntax-model.html#%28tech._syntax._transformer%29) application by the expander or while a module is [visit](syntax-model.html#%28tech._visit%29)ed (see [syntax-transforming?](#%28def._%28%28quote._~23~25kernel%29._syntax-transforming~3f%29%29)), otherwise the [exn:fail:contract](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29) exception is raised.
> ```
(parameter)	→


# 12.2 Syntax Object Content
```
(parameter)	→```

Cooperates with the [module](module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29) form to insert stx as a top-level declaration at the end of the module currently being expanded. If the current expression being transformed is in [phase level](syntax-model.html#%28tech._phase._level%29) 0 and not in the module top-level, then stx is eventually expanded in an expression context. If the current expression being transformed is in a higher [phase level](syntax-model.html#%28tech._phase._level%29) (i.e., nested within some number of [begin-for-syntax](begin.html#%28form._%28%28quote._~23~25kernel%29._begin-for-syntax%29%29)es within a module top-level), then the lifted declaration is placed at the very end of the module (under a suitable number of [begin-for-syntax](begin.html#%28form._%28%28quote._~23~25kernel%29._begin-for-syntax%29%29)es), instead of merely the end of the enclosing [begin-for-syntax](begin.html#%28form._%28%28quote._~23~25kernel%29._begin-for-syntax%29%29).

This procedure must be called during the dynamic extent of a [syntax transformer](syntax-model.html#%28tech._syntax._transformer%29) application by the expander or while a module is [visit](syntax-model.html#%28tech._visit%29)ed (see [syntax-transforming?](#%28def._%28%28quote._~23~25kernel%29._syntax-transforming~3f%29%29)), otherwise the [exn:fail:contract](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29) exception is raised.

If the current expression being transformed is not within a [module](module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29) form (see [syntax-transforming-module-expression?](#%28def._%28%28quote._~23~25kernel%29._syntax-transforming-module-expression~3f%29%29)), then the [exn:fail:contract](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29) exception is raised.

> ```
(syntax-local-lift-require raw-require-spec
    stx
   [ new-scope?)    →    syntax?

  raw-require-spec : any/c
  stx : syntax?
  new-scope? : any/c = #t
```


# 12.2 Syntax Object Content
(parameter)	→```
Lifts a [#%provide](require.html#%28form._%28%28quote._~23~25kernel%29._~23~25provide%29%29) form corresponding to raw-provide-spec-stx to the top of the module currently being expanded or to an enclosing [begin-for-syntax](begin.html#%28form._%28%28quote._~23~25kernel%29._begin-for-syntax%29%29).
This procedure must be called during the dynamic extent of a [syntax transformer](syntax-model.html#%28tech._syntax._transformer%29) application by the expander or while a module is [visit](syntax-model.html#%28tech._visit%29)ed (see [syntax-transforming?](#%28def._%28%28quote._~23~25kernel%29._syntax-transforming~3f%29%29)), otherwise the [exn:fail:contract](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29) exception is raised.
If the current expression being transformed is not within a [module](module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29) form (see [syntax-transforming-module-expression?](#%28def._%28%28quote._~23~25kernel%29._syntax-transforming-module-expression~3f%29%29)), then the [exn:fail:contract](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29) exception is raised.
> ```
(syntax-local-name)  →  any/c


# 12.2 Syntax Object Content
```
Returns an inferred name for the expression position being transformed, or #f if no such name is available. A name is normally a symbol or an identifier. See also Inferred Value Names.

This procedure must be called during the dynamic extent of a syntax transformer application by the expander or while a module is visited (see syntax-transforming?), otherwise the exn:fail:contract exception is raised.

> ```
(syntax-local-context)
   →   (or/c 'expression 'top-level 'module 'module-begin list?)```

Returns an indication of the context for expansion that triggered a [syntax transformer](syntax-model.html#%28tech._syntax._transformer%29) call. See [Expansion Context](syntax-model.html#%28part._expand-context-model%29) for more information on contexts.

The symbol results indicate that the expression is being expanded for an [expression context](syntax-model.html#%28tech._expression._context%29), a [top-level context](syntax-model.html#%28tech._top._level._context%29), a [module context](syntax-model.html#%28tech._module._context%29), or a [module-begin context](syntax-model.html#%28tech._module._begin._context%29).

A list result indicates expansion in an [internal-definition context](syntax-model.html#%28tech._internal._definition._context%29). The identity of the list’s first element (i.e., its [eq?](Equality.html#%28def._%28%28quote._~23~25kernel%29._eq~3f%29%29)ness) reflects the identity of the internal-definition context; in particular two transformer expansions receive the same first value if and only if they are invoked for the same [internal-definition context](syntax-model.html#%28tech._internal._definition._context%29). Later values in the list similarly identify [internal-definition contexts](syntax-model.html#%28tech._internal._definition._context%29) that are still being expanded, and that required the expansion of nested internal-definition contexts.

This procedure must be called during the dynamic extent of a [syntax transformer](syntax-model.html#%28tech._syntax._transformer%29) application by the expander or while a module is [visit](syntax-model.html#%28tech._visit%29)ed (see [syntax-transforming?](#%28def._%28%28quote._~23~25kernel%29._syntax-transforming~3f%29%29)), otherwise the [exn:fail:contract](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29) exception is raised.

> ```
(syntax-local-phase-level)  →  exact-integer?
```


# 12.2 Syntax Object Content
(parameter)	→
(-> listof (cons/c phase+space? (listof symbol?)))```
Returns an association list from [phase level](syntax-model.html#%28tech._phase._level%29) and [binding space](syntax-model.html#%28tech._binding._space%29) combinations to lists of symbols, where the symbols are the names of [provide](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._provide%29%29)d bindings from mod-path at the corresponding [phase level](syntax-model.html#%28tech._phase._level%29).
This procedure must be called during the dynamic extent of a [syntax transformer](syntax-model.html#%28tech._syntax._transformer%29) application by the expander or while a module is [visit](syntax-model.html#%28tech._visit%29)ed (see [syntax-transforming?](#%28def._%28%28quote._~23~25kernel%29._syntax-transforming~3f%29%29)), otherwise the [exn:fail:contract](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29) exception is raised.
Changed in version 8.2.0.3 of package base: Generalized result to phase–space combinations.
> ```
(syntax-local-submodules)	→
(-> listof symbol?)


# 12.2 Syntax Object Content
```
(syntax-local-module-interned-scope-symbols)	→
(-> listof symbol?)```

Returns a list of distinct [interned](reader.html#%28tech._interned%29) symbols corresponding to [binding spaces](syntax-model.html#%28tech._binding._space%29) that have been used, so far, for binding within the current expansion context’s module or top-level namespace. The result is conservative in the sense that it may include additional symbols that have not been used in the current module or namespace.

The current implementation returns all symbols for [reachable](eval-model.html#%28tech._reachable%29) interned scopes, but that behavior may change in the future to return a less conservative list of symbols.

This procedure must be called during the dynamic extent of a [syntax transformer](syntax-model.html#%28tech._syntax._transformer%29) application by the expander or while a module is [visit](syntax-model.html#%28tech._visit%29)ed (see [syntax-transforming?](#%28def._%28%28quote._~23~25kernel%29._syntax-transforming~3f%29%29)), otherwise the [exn:fail:contract](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29) exception is raised.

Added in version 8.2.0.7 of package base.

> ```
(syntax-local-get-shadower id-stx
   [ only-generated?)    →    identifier?

  id-stx : identifier?
  only-generated? : any/c = #f
```
(parameter)	→```
For (limited) backward compatibility only; raises [exn:fail:unsupported](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3aunsupported%29%29).


# 12.2 Syntax Object Content
Changed in version 6.3 of package base: changed to raise exn:fail:supported.
> ```
(syntax-local-certifier [active?)
   →    ( ( syntax? ) ( any/c ( or/c procedure? #f ) )
> .  →  * . syntax? )
  active? : boolean? = #f
```
For backward compatibility only; returns a procedure that returns its first argument.

> ```
(syntax-transforming?)   →   boolean?```

Returns #t during the dynamic extent of a [syntax transformer](syntax-model.html#%28tech._syntax._transformer%29) application by the expander and while a module is being [visit](syntax-model.html#%28tech._visit%29)ed, #f otherwise.

> ```
(syntax-transforming-with-lifts?)  →  boolean?
```
Returns #t if (syntax-transforming?) produces #t and a target context is available for lifting expressions (via syntax-local-lift-expression), #f otherwise.
Currently, (syntax-transforming?) implies (syntax-transforming-with-lifts?).
Added in version 6.3.0.9 of package base.
> ```
(syntax-transforming-module-expression?)   →   boolean?```
Returns #t during the dynamic extent of a [syntax transformer](syntax-model.html#%28tech._syntax._transformer%29) application by the expander for an expression within a [module](module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29) form, #f otherwise.
> ```
(syntax-local-compiling-module?)  →  boolean?


# 12.2 Syntax Object Content
```
Returns #t during the dynamic extent of a syntax transformer application by the expander in a module-begin context and when the expansion is part of a compilation process where a compiled module can be returned directly. See also module.

Added in version 8.13.0.7 of package base.

> ```
(syntax-local-identifier-as-binding id-stx
   [ intdef-ctx)    →    identifier?

  id-stx : identifier?
  intdef-ctx : (or/c internal-definition-context? #f) = #f```

Returns an identifier like id-stx, but without [use-site scopes](syntax-model.html#%28tech._use._site._scope%29) that were previously added to the identifier as part of a macro expansion. When the intdef-ctx is an internal-definition context, the function removes use-site scopes created during expansion in that context. When it is #f (the default), it removes use-site scopes created during expansion in the current expansion context.

In a [syntax transformer](syntax-model.html#%28tech._syntax._transformer%29) that runs in a non-expression context and forces the expansion of subforms with [local-expand](#%28def._%28%28quote._~23~25kernel%29._local-expand%29%29), use [syntax-local-identifier-as-binding](#%28def._%28%28quote._~23~25kernel%29._syntax-local-identifier-as-binding%29%29) on an identifier from the expansion before moving it into a binding position or comparing it with [bound-identifier=?](stxcmp.html#%28def._%28%28quote._~23~25kernel%29._bound-identifier~3d~3f%29%29). Otherwise, the results can be inconsistent with the way that [define](define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29) works in the same definition context.

This procedure must be called during the dynamic extent of a [syntax transformer](syntax-model.html#%28tech._syntax._transformer%29) application by the expander or while a module is [visit](syntax-model.html#%28tech._visit%29)ed (see [syntax-transforming?](#%28def._%28%28quote._~23~25kernel%29._syntax-transforming~3f%29%29)), otherwise the [exn:fail:contract](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29) exception is raised.

Added in version 6.3 of package base.
Changed in version 8.2.0.7: Added the optional intdef-ctx argument.

> ```
(syntax-local-introduce stx)  →  syntax?
  stx : syntax?
```


# 12.2 Syntax Object Content
Produces a syntax object that is like stx, except that the presence of scopes for the current expansion—both the macro-introduction scope and the use-site scope, if any—is flipped on all parts of the syntax object. See Transformer Bindings for information on macro-introduction and use-site scopes.
This procedure must be called during the dynamic extent of a syntax transformer application by the expander or while a module is visited (see syntax-transforming?), otherwise the exn:fail:contract exception is raised.
Example:
> ```racket
> > ( module example racket ( define-syntax ( require-math stx ) ( syntax-local-introduce #' ( require racket/math ) ) ) ( require-math ) pi )
> ```
> ```
(make-syntax-introducer [as-use-site?)
   →   ((syntax?) ((or/c 'flip 'add 'remove)) .  →  * . syntax?)
  as-use-site? : any/c = #f```
Produces a procedure that encapsulates a fresh [scope](syntax-model.html#%28tech._scope%29) and flips, adds, or removes it in a given syntax object. By default, the fresh scope is a [macro-introduction scope](syntax-model.html#%28tech._macro._introduction._scope%29), but providing a true value for as-use-site? creates a scope that is like a [use-site scope](syntax-model.html#%28tech._use._site._scope%29); the difference is in how the scopes are treated by [syntax-original?](stxops.html#%28def._%28%28quote._~23~25kernel%29._syntax-original~3f%29%29).


# 12.2 Syntax Object Content
The action of the generated procedure can be 'flip (the default) to flip the presence of a scope in each part of a given syntax object, 'add to add the scope to each regardless of whether it is present already, or 'remove to remove the scope when it is currently present in any part.
Multiple applications of the same [make-syntax-introducer](#%28def._%28%28quote._~23~25kernel%29._make-syntax-introducer%29%29) result procedure use the same scope, and different result procedures use distinct scopes.
Changed in version 6.3 of package base: Added the optional as-use-site? argument, and added the optional operation argument in the result procedure.
> ```
(parameter)	→
(-> (syntax?) ((or/c 'flip 'add 'remove)) . → * . syntax?)


# 12.2 Syntax Object Content
```
Like make-syntax-introducer, but the encapsulated scope is an interned scope. Multiple calls to make-interned-syntax-introducer with the same key will produce procedures that flip, add, or remove the same scope, even across phases and module instantiations. Furthermore, the scope remains consistent even when embedded in compiled code, so a scope created with make-interned-syntax-introducer will retain its identity in syntax objects loaded from compiled code. (In this sense, the relationship between make-syntax-introducer and make-interned-syntax-introducer is analogous to the relationship between gensym and quote.)

This function is intended for the implementation of separate binding spaces within a single phase, for which the scope associated with each environment must be the same across modules.

Unlike make-syntax-introducer, the scope added by a procedure created with make-interned-syntax-introducer is always treated like a use-site scope, not a macro-introduction scope, so it does not affect originalness as reported by syntax-original?.

Added in version 6.90.0.28 of package base.
Changed in version 8.2.0.4: Added the constraint that key is interned.

> ```
(make-syntax-delta-introducer ext-stx
    base-stx
   [ phase-level)

   →   ((syntax?) ((or/c 'flip 'add 'remove)) .  →  * . syntax?)
  ext-stx : identifier?
  base-stx : (or/c syntax? #f)
   phase-level   :   (or/c #f exact-integer?)
      =   (syntax-local-phase-level)```

Produces a procedure that behaves like the result of [make-syntax-introducer](#%28def._%28%28quote._~23~25kernel%29._make-syntax-introducer%29%29), but using a set of [scopes](syntax-model.html#%28tech._scope%29) from ext-stx and with a default action of 'add.

-   If the scopes of base-stx are a subset of the scopes of ext-stx, then the result of [make-syntax-delta-introducer](#%28def._%28%28quote._~23~25kernel%29._make-syntax-delta-introducer%29%29) adds, removes, or flips scopes that are in the set for ext-stx and not in the set for base-stx.

-   If the scopes of base-stx are not a subset of the scopes of ext-stx, but if it has a binding, then the set of scopes associated with the binding id subtracted from the set of scopes for ext-stx, and the result of [make-syntax-delta-introducer](#%28def._%28%28quote._~23~25kernel%29._make-syntax-delta-introducer%29%29) adds, removes, or flips that difference.

A #f value for base-stx is equivalent to a syntax object with no [scopes](syntax-model.html#%28tech._scope%29).

This procedure is potentially useful when some m-id has a transformer binding that records some orig-id, and a use of m-id introduces a binding of orig-id. In that case, the [scopes](syntax-model.html#%28tech._scope%29) one the use of m-id added since the binding of m-id should be transferred to the binding instance of orig-id, so that it captures uses with the same lexical context as the use of m-id.

If ext-stx is [tainted](stxcerts.html#%28tech._tainted%29), then an identifier result from the created procedure is [tainted](stxcerts.html#%28tech._tainted%29).

> ```
(syntax-local-transforming-module-provides?)  →  boolean?
```


# 12.2 Syntax Object Content
Returns #t while a provide transformer is running (see make-provide-transformer) or while an expand sub-form of #%provide is expanded, #f otherwise.
> ```
(syntax-local-module-defined-identifiers)
   →   (and/c hash? immutable?)```
Can be called only while [syntax-local-transforming-module-provides?](#%28def._%28%28quote._~23~25kernel%29._syntax-local-transforming-module-provides~3f%29%29) returns #t.
It returns a hash table mapping a [phase-level](syntax-model.html#%28tech._phase._level%29) number (such as 0) to a list of all definitions at that [phase level](syntax-model.html#%28tech._phase._level%29) within the module being expanded. This information is used for implementing [provide](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._provide%29%29) sub-forms like [all-defined-out](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._all-defined-out%29%29).
Beware that the [phase-level](syntax-model.html#%28tech._phase._level%29) keys are absolute relative to the enclosing module, and not relative to the current transformer phase level as reported by [syntax-local-phase-level](#%28def._%28%28quote._~23~25kernel%29._syntax-local-phase-level%29%29).
> ```
(syntax-local-module-required-identifiers   mod-path
    shift)
   →    ( or/c ( listof ( cons/c phase+space?
> ( listof identifier? ) ) )
> #f )
  mod-path : (or/c module-path? #f)
  shift : (or/c #t phase+space-shift?)


# 12.2 Syntax Object Content
```
Can be called only while syntax-local-transforming-module-provides? returns #t.

It returns an association list mapping phase level and binding space combinations to lists of identifiers. Each list of identifiers includes all bindings imported (into the module being expanded) using the module path mod-path, or all modules if mod-path is #f. The association list includes all identifiers imported with a phase level and binding space shift as represented by shift, or all shifts if shift is #t. If shift is not #t, the result can be #f if no identifiers are imported at that shift.

When an identifier is renamed on import, the result association list includes the identifier by its internal name. Use identifier-binding to obtain more information about the identifier.

Beware that the phase-level shifts are absolute relative to the enclosing module, and not relative to the current transformer phase level as reported by syntax-local-phase-level.

Changed in version 8.2.0.3 of package base: Generalized shift and result to phase–space combinations.

> ```
value

prop:liberal-define-context : struct-type-property?

(liberal-define-context? v)   →   boolean?
  v : any/c```

An instance of a structure type with a true value for the [prop:liberal-define-context](#%28def._%28%28quote._~23~25kernel%29._prop~3aliberal-define-context%29%29) property can be used as an element of an [internal-definition context](syntax-model.html#%28tech._internal._definition._context%29) representation in the result of [syntax-local-context](#%28def._%28%28quote._~23~25kernel%29._syntax-local-context%29%29) or the second argument of [local-expand](#%28def._%28%28quote._~23~25kernel%29._local-expand%29%29). Such a value indicates that the context supports liberal expansion of [define](define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29) forms into potentially multiple [define-values](define.html#%28form._%28%28quote._~23~25kernel%29._define-values%29%29) and [define-syntaxes](define.html#%28form._%28%28quote._~23~25kernel%29._define-syntaxes%29%29) forms. The 'module and 'module-body contexts implicitly allow [liberal expansion](#%28tech._liberal._expansion%29).

The [liberal-define-context?](#%28def._%28%28quote._~23~25kernel%29._liberal-define-context~3f%29%29) predicate returns #t if v is an instance of a structure with a true value for the [prop:liberal-define-context](#%28def._%28%28quote._~23~25kernel%29._prop~3aliberal-define-context%29%29) property, #f otherwise.

#### 12.4.1 [require](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) Transformers

|                                                                                |                                                                                |
|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------:|
|  ([require](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) [racket/require-transform](#%28mod-path._racket%2Frequire-transform%29)) |  package: [base](https://pkgs.racket-lang.org/package/base "Install this package using `raco pkg install base`") |

The bindings documented in this section are provided by the [racket/require-transform](#%28mod-path._racket%2Frequire-transform%29) library, not [racket/base](index.html) or [racket](index.html).

A [transformer](syntax-model.html#%28tech._transformer%29) binding whose value is a structure with the [prop:require-transformer](#%28def._%28%28lib._racket%2Frequire-transform..rkt%29._prop~3arequire-transformer%29%29) property implements a derived require-spec for [require](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) as a require transformer.

A [require transformer](#%28tech._require._transformer%29) is called with the syntax object representing its use as a require-spec within a [require](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) form, and the result must be two lists: a list of [import](#%28def._%28%28lib._racket%2Frequire-transform..rkt%29._import%29%29)s and a list of [import-source](#%28def._%28%28lib._racket%2Frequire-transform..rkt%29._import-source%29%29)s.

If the derived form contains a sub-form that is a require-spec, then it can call [expand-import](#%28def._%28%28lib._racket%2Frequire-transform..rkt%29._expand-import%29%29) to transform the sub-require-spec to lists of imports and import sources.

See also [define-require-syntax](define.html#%28form._%28%28lib._racket%2Frequire-syntax..rkt%29._define-require-syntax%29%29), which supports macro-style [require](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) transformers.

> ```
(expand-import require-spec)
   →    (listof import?)   (listof import-source?)

  require-spec : syntax?
```


# 12.2 Syntax Object Content
Expands the given require-spec to lists of imports and import sources. The latter specifies modules to be instantiated or visited, so the modules that it represents should be a superset of the modules represented in the former list (so that a module will be instantiated or visited even if all of imports are eventually filtered from the former list).
> ```
(make-require-transformer proc)   →   require-transformer?
   proc   :   ( syntax? .  →  . ( values
> ( listof import? )
> ( listof import-source? ) ) )```
Creates a [require transformer](#%28tech._require._transformer%29) using the given procedure as the transformer. Often used in combination with [expand-import](#%28def._%28%28lib._racket%2Frequire-transform..rkt%29._expand-import%29%29).
Examples:
> ```racket
> > ( require ( for-syntax racket/require-transform ) )
> > ( define-syntax printing ( make-require-transformer ( lambda ( stx ) ( syntax-case stx ( ) [ ( _ path ) ( begin ( printf "Importing: ~a~n" #' path ) ( expand-import #' path ) ) ] ) ) ) )
> > ( require ( printing racket/match ) )
> Importing: #<syntax:eval:37:0 racket/match>
> ```
>
<colgroup><col style="width: 100%" /></colgroup>

value

[prop:require-transformer](#%28def._%28%28lib._racket%2Frequire-transform..rkt%29._prop~3arequire-transformer%29%29) : [struct-type-property?](structprops.html#%28def._%28%28quote._~23~25kernel%29._struct-type-property~3f%29%29)


# 12.2 Syntax Object Content
A property to identify [require transformers](#%28tech._require._transformer%29). The property value must be a procedure that takes the structure and returns a transformer procedure; the returned transformer procedure takes a syntax object and returns import and import-source lists.
> ```
(require-transformer? v)  →  boolean?
  v : any/c
```
(current-require-module-path)	→
(-> or/c #f module-path-index?)
(current-require-module-path module-path) → void?
    module-path	:
(-> or/c #f module-path-index?)```

A [parameter](eval-model.html#%28tech._parameter%29) that determines how relative [require](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29)-level module paths are expanded to [#%require](require.html#%28form._%28%28quote._~23~25kernel%29._~23~25require%29%29)-level module paths by [convert-relative-module-path](#%28def._%28%28lib._racket%2Frequire-transform..rkt%29._convert-relative-module-path%29%29) (which is used implicitly by all built-in [require](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) sub-forms).

When the value of [current-require-module-path](#%28def._%28%28lib._racket%2Frequire-transform..rkt%29._current-require-module-path%29%29) is #f, relative module paths are left as-is, which means that the [require](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) context determines the resolution of the module path.

The [require](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) form [parameterize](parameters.html#%28form._%28%28lib._racket%2Fprivate%2Fmore-scheme..rkt%29._parameterize%29%29)s [current-require-module-path](#%28def._%28%28lib._racket%2Frequire-transform..rkt%29._current-require-module-path%29%29) as #f while invoking sub-form transformers, while [relative-in](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._relative-in%29%29) [parameterize](parameters.html#%28form._%28%28lib._racket%2Fprivate%2Fmore-scheme..rkt%29._parameterize%29%29)s to a given module path.

> ```
(convert-relative-module-path module-path)
   →    ( or/c module-path?
> ( syntax/c module-path? ) )

   module-path   :   ( or/c module-path?
> ( syntax/c module-path? ) )
```


# 12.2 Syntax Object Content
(parameter)	→```
Lifts top-level-stx to the top-level of the enclosing module, immediately following the [require](require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29) that is being expanded.
This procedure must be called during the dynamic extent of a [syntax transformer](syntax-model.html#%28tech._syntax._transformer%29) application by the expander or while a module is [visit](syntax-model.html#%28tech._visit%29)ed (see [syntax-transforming?](#%28def._%28%28quote._~23~25kernel%29._syntax-transforming~3f%29%29)), otherwise the [exn:fail:contract](exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29) exception is raised.
In addition, this procedure may only be called while expanding a [require transformer](#%28tech._require._transformer%29).
Added in version 8.12.0.13 of package base.
> ```
(syntax-local-require-certifier)
   →    ( ( syntax? ) ( or/c #f ( syntax? .  →  . syntax? ) )
> .  →  * . syntax? )