Next: , Previous: , Up: iklib syntaxes   [Index]


6.8.4 define-syntax–like additional syntaxes

Syntax: define-syntax ?name
Syntax: define-syntax ?name ?transformer
Syntax: define-syntax (?name ?arg) ?body0 ?body

Vicare extends define-syntax as defined by R6RS; it additionally accepts the syntax:

(define-syntax (?name ?arg) ?body0 ?body …)
→ (define-syntax ?name (lambda (?arg) ?body0 ?body …))

and the syntax:

(define-syntax ?name)
→ (define-syntax ?name (syntax-rules ()))

Additionally, when the last form is used:

Syntax: define-constant ?var ?expr

Like define but create an immutable binding.

(define-constant X 1)
X               ⇒ 1
(set! X 2)      error→ &syntax
Syntax: define-syntax-rule (?name ?pattern … . ?rest) ?body0 ?body

Convenience syntax to define a syntax-rules transformer with a single clause. Expand to:

(define-syntax-rule (?name ?pattern … . ?rest)
  ?body0 ?body …)
→ (define-syntax ?name
      (syntax-rules ()
        ((_ ?pattern … . ?rest)
         (begin ?body0 ?body …))))
Syntax: define-auxiliary-syntaxes ?name0 ?name

Define auxiliary syntaxes to be used as literal identifiers by syntax-rules, syntax-case and similar macros; expand to:

(define-syntax ?name0 (syntax-rules ()))
(define-syntax ?name  (syntax-rules ()))
…
Syntax: define-alias ?alias-id ?old-id

Define a new binding for ?alias-id as an alias for ?old-id, which must be a bound identifier in the current lexical environment.

(let ((a 1))
  (define-alias b a)
  b)
⇒ 1

Next: , Previous: , Up: iklib syntaxes   [Index]