On this page:
macro

11 Macros🔗

syntax

(macro (name pattern ...) directive ... template)

syntax

(macro name parse-option ... [pattern directive ... template] ...)

A unified way to define macros, both for the host language as well as native DSLs.

Ordinarily, this defines host language macros, and is identical to either Racket’s define-syntax-parse-rule or define-syntax-parser, depending on whether the simple rewrite pattern or the dispatch pattern is used.

(macro (where expr bindings)
  (def bindings expr))
(macro hello
  [(_ name) #'(displayln (format "hello ~a" name))]
  [(_) #'(displayln (format "hello ~a" "world"))])

If the pattern is prefixed with ☯, this defines Qi macros, and is identical to Qi’s define-qi-syntax-rule or define-qi-syntax-parser, depending on the pattern used.

(macro (<~ f g)
  (~> g f))
 
(map (<~ add1 sqr) [1 2 3])