On this page:

11.8 Syntax Taints

+Syntax Taints in The Racket Guide introduces syntax taints.

The tamper status of a syntax object is either tainted, armed, or clean:

Taints cannot be removed, and attempting to arm a syntax object that is already tainted has no effect on the resulting syntax object.

The macro expander disarms any syntax object that it encounters in an expression position or as a module body. A syntax object is therefore disarmed when it is provided to a syntax transformer. The transformer’s result, however, is rearmed by copying to it any dye packs that were originally attached to the transformer’s input. The rearming process obeys the following rules:

For backward compatibility, a 'certify-mode property is treated the same as a 'taint-mode property if the former is not attached. To avoid accidental transfer of a 'taint-mode or 'certify-mode property value, the expander always removes any 'taint-mode and 'certify-mode property on a syntax object that is passed to a syntax transformer.

(syntax-tainted? stx)  boolean?
  stx : syntax?
Returns #t if stx is tainted, #f otherwise.

(syntax-arm stx [inspector use-mode?])  syntax?
  stx : syntax?
  inspector : (or/c inspector? #f) = #f
  use-mode? : any/c = #f
Produces a syntax object like stx, but armed with a dye pack that is keyed by inspector.

A #f value for inspector is equivalent to an inspector that depends on the current dynamic context:

If use-mode? is #f, then if stx is tainted or already armed with the key inspector, the result is stx.

If use-mode? is a true value, then a dye pack is not necessarily added directly to stx. Instead, the dye pack is pushed to interior syntax objects in the same way that the expander pushes armings into a syntax transformer’s results when rearming (based on a 'taint-mode syntax property or identifier bindings); see the expander’s rearming rules for more information. To the degree that pushing dye packs into a syntax object must destructure stx, existing taints or dye packs can lead to tainted results rather than armed results.

(syntax-protect stx)  syntax?
  stx : syntax?
Equivalent to (syntax-arm stx #f #f #t).

(syntax-disarm stx inspector)  syntax?
  stx : syntax?
  inspector : (or/c inspector? #f)
Produces a disarmed version of stx, removing any immediate dye packs that match inspector. An inspector matches when it is either the same as or a super-inspector of the dye pack’s inspector. A #f value for inspector is replaced by a specific inspector in the same way as for syntax-arm.

(syntax-rearm stx from-stx [use-mode?])  syntax?
  stx : syntax?
  from-stx : syntax?
  use-mode? : any/c = #f
Produces a rearmed or tainted version of stx by adding all immediate taints and dye packs of from-stx.

If use-mode? is a true value, stx is not necessarily tainted or armed directly. Instead, taints or dye packs are pushed to interior syntax objects in the same way as for syntax-arm or rearming by the expander.

(syntax-taint stx)  syntax?
  stx : syntax?
Returns tainted version of stxequivalent to (datum->syntax (syntax-arm stx) (syntax-e stx) stx stx)or stx if it is already tainted.