On this page:
format-unique-id
syntax-map
syntax-list
29.1 Syntax Object Source Locations
syntax-source-directory
syntax-source-file-name
Version: 5.1.1

29 Syntax

Ryan Culpepper <ryanc@racket-lang.org>

 (require unstable/syntax)

This library is unstable; compatibility will not be maintained. See Unstable for more information.

This binding was added by Vincent St-Amour.

(format-unique-id lctx    
  [#:source src    
  #:props props    
  #:cert cert]    
  fmt    
  v ...)  identifier?
  lctx : (or/c syntax? #f)
  src : (or/c syntax? #f) = #f
  props : (or/c syntax? #f) = #f
  cert : (or/c syntax? #f) = #f
  fmt : string?
  v : (or/c string? symbol? identifier? keyword? char? number?)
Like format-id, but returned identifiers are guaranteed to be unique.

The subsequent bindings were added by Sam Tobin-Hochstadt.

(syntax-map f stxl ...)  (listof A)
  f : (-> syntax? A)
  stxl : syntax?
Performs (map f (syntax->list stxl) ...).

Example:

> (syntax-map syntax-e #'(a b c))

'(a b c)

The subsequent bindings were added by Carl Eastlund <cce@racket-lang.org>.

(syntax-list template ...)
This form constructs a list of syntax objects based on the given templates. It is equivalent to (syntax->list #'(template ...)).

Example:

> (with-syntax ([(x ...) #'(1 2 3)])  (syntax-list x ...))

'(#<syntax:3:0 1> #<syntax:3:0 2> #<syntax:3:0 3>)

29.1 Syntax Object Source Locations

(syntax-source-directory stx)  (or/c path? #f)
  stx : syntax?
(syntax-source-file-name stx)  (or/c path? #f)
  stx : syntax?
These produce the directory and file name, respectively, of the path with which stx is associated, or #f if stx is not associated with a path.

Examples:

(define loc
  (list (build-path "/tmp" "dir" "somewhere.ss")
        #f #f #f #f))
(define stx1 (datum->syntax #f 'somewhere loc))
> (syntax-source-directory stx1)

#<path:/tmp/dir/>

> (syntax-source-file-name stx1)

#<path:somewhere.ss>

(define stx2 (datum->syntax #f 'nowhere #f))
> (syntax-source-directory stx2)

#f

> (syntax-source-directory stx2)

#f