On this page:
bound-identifier=?
free-identifier=?
free-transformer-identifier=?
free-template-identifier=?
free-label-identifier=?
check-duplicate-identifier
identifier-binding
identifier-transformer-binding
identifier-template-binding
identifier-label-binding
identifier-binding-symbol

12.3 Syntax Object Bindings

procedure

(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 indicated by phase-level, #f otherwise. A #f value for phase-level corresponds to the label phase level.

Examples:
> (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

procedure

(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
Returns #t if a-id and b-id access the same local binding, module binding, or top-level bindingperhaps via rename transformersat 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:
> (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>)

procedure

(free-transformer-identifier=? a-id b-id)  boolean?

  a-id : identifier?
  b-id : identifier?

procedure

(free-template-identifier=? a-id b-id)  boolean?

  a-id : identifier?
  b-id : identifier?

procedure

(free-label-identifier=? a-id b-id)  boolean?

  a-id : identifier?
  b-id : identifier?
Same as (free-identifier=? a-id b-id #f).

procedure

(check-duplicate-identifier ids)  (or/c identifier? #f)

  ids : (listof identifier?)
Compares each identifier in ids with every other identifier in the list with bound-identifier=?. If any comparison returns #t, one of the duplicate identifiers is returned (the first one in ids that is a duplicate), otherwise the result is #f.

procedure

(identifier-binding id-stx 
  [phase-level 
  top-level-symbol?]) 
  
(or/c 'lexical
      #f
      (list/c module-path-index?
              symbol?
              module-path-index?
              symbol?
              exact-nonnegative-integer?
              (or/c exact-integer? #f)
              (or/c exact-integer? #f))
      (list/c symbol?))
  id-stx : identifier?
  phase-level : (or/c exact-integer? #f)
   = (syntax-local-phase-level)
  top-level-symbol? : any/c = #f
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 indicated by phase-level (where a #f value for phase-level corresponds to the label phase level):

If id-stx is bound to a rename-transformer, the result from identifier-binding is for the identifier in the transformer, so that identifier-binding is consistent with free-identifier=?.

Changed in version 6.6.0.4 of package base: Added the top-level-symbol? argument to report information on top-level bindings.

procedure

(identifier-transformer-binding id-stx 
  [rt-phase-level]) 
  
(or/c 'lexical
      #f
      (listof module-path-index?
              symbol?
              module-path-index?
              symbol?
              exact-nonnegative-integer?
              (or/c exact-integer? #f)
              (or/c exact-integer? #f)))
  id-stx : identifier?
  rt-phase-level : (or/c exact-integer? #f)
   = (syntax-local-phase-level)
Same as (identifier-binding id-stx (and rt-phase-level (add1 rt-phase-level))).

procedure

(identifier-template-binding id-stx)

  
(or/c 'lexical
      #f
      (listof module-path-index?
              symbol?
              module-path-index?
              symbol?
              exact-nonnegative-integer?
              (or/c exact-integer? #f)
              (or/c exact-integer? #f)))
  id-stx : identifier?

procedure

(identifier-label-binding id-stx)

  
(or/c 'lexical
      #f
      (listof module-path-index?
              symbol?
              module-path-index?
              symbol?
              exact-nonnegative-integer?
              (or/c exact-integer? #f)
              (or/c exact-integer? #f)))
  id-stx : identifier?
Same as (identifier-binding id-stx #f).

procedure

(identifier-binding-symbol id-stx    
  [phase-level])  symbol?
  id-stx : identifier?
  phase-level : (or/c exact-integer? #f)
   = (syntax-local-phase-level)
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.