Previous: , Up: iklib expander   [Index]


6.14.10 Synonym transformers

Synonym transformers allow the creation of multiple identifiers which resolve to the same syntactic binding. Usage examples:

(import (vicare))

(define a 1)

(define-syntax b
  (make-synonym-transformer #'a))

(list a b)      ⇒ (1 1)

(define-syntax c
  (make-synonym-transformer #'b))

(list a b c)    ⇒ (1 1 1)

(define-syntax d
  (make-synonym-transformer #'b))

(set! c 2)

(list a b c d)  ⇒ (2 2 2 2)

Circular references are detected and cause a syntax violation to be raised.

If the identifier id1 is bound to a synonym transformer with source identifier id2: the two identifiers resolve to the same syntactic binding but are not free-identifier=?. To create an identifier that is free-identifier=? to another we have to use define-alias.

Function: make-synonym-transformer id

Build and return a “special” value that, when used as right–hand side of a syntax definition, is recognised by the expander as a synonym transformer as opposed to a normal transformer, variable transformer or a compile–time value. id must be the source identifier.

Function: synonym-transformer? obj

Return #t if obj is recognised by the expander as a synonym transformer as opposed to a normal transformer, variable transformer or a compile–time value; otherwise return #f.

Function: synonym-transformer-identifier obj

If obj is recognised by the expander as a synonym transformer: return the source identifier, otherwise raise an exception.