12.11 Syntax Utilities
(require racket/syntax) | package: base |
12.11.1 Creating formatted identifiers
procedure
(format-id lctx fmt v ... [ #:source src #:props props #:cert ignored]) → identifier? lctx : (or/c syntax? #f) fmt : string? v : (or/c string? symbol? identifier? keyword? char? number?) src : (or/c syntax? #f) = #f props : (or/c syntax? #f) = #f ignored : (or/c syntax? #f) = #f
The format string must use only ~a placeholders. Identifiers in the argument list are automatically converted to symbols.
Examples: | |||||||||||||||||||||||
|
(Scribble doesn’t show it, but the DrRacket pinpoints the location of the second error but not of the first.)
procedure
(format-symbol fmt v ...) → symbol?
fmt : string? v : (or/c string? symbol? identifier? keyword? char? number?)
Example: | ||
|
12.11.2 Pattern variables
syntax
(define/with-syntax pattern stx-expr)
stx-expr : syntax?
Examples: | |||||||||||||
|
12.11.3 Error reporting
parameter
(current-syntax-context stx) → void? stx : (or/c syntax? false/c)
procedure
(wrong-syntax stx format-string v ...) → any
stx : syntax? format-string : string? v : any/c
Examples: | ||||||||
|
(define-syntax (my-macro stx) (parameterize ([current-syntax-context stx]) (syntax-case stx () __)))
12.11.4 Recording disappeared uses
parameter
→ (or/c (listof identifier?) false/c) (current-recorded-disappeared-uses ids) → void? ids : (or/c (listof identifier?) false/c)
syntax
(with-disappeared-uses stx-expr)
stx-expr : syntax?
procedure
(syntax-local-value/record id predicate) → any/c
id : identifier? predicate : (-> any/c boolean?)
procedure
(record-disappeared-uses ids) → void?
ids : (listof identifier?)
If not used within the extent of a with-disappeared-uses form or similar, has no effect.
12.11.5 Miscellaneous utilities
procedure
(generate-temporary [name-base]) → identifier?
name-base : any/c = 'g
procedure
(internal-definition-context-apply intdef-ctx stx) → syntax? intdef-ctx : internal-definition-context? stx : syntax?
procedure
(syntax-local-eval stx [intdef-ctx]) → any
stx : syntax? intdef-ctx : (or/c internal-definition-context? #f) = #f
Examples: | |||||||||||||||||||||||||||||
|
syntax
(with-syntax* ([pattern stx-expr] ...) body ...+)
stx-expr : syntax?
Example: | |||||
|