Skip to content

Instantly share code, notes, and snippets.

@ktakashi
Created August 19, 2015 19:58
Show Gist options
  • Save ktakashi/21cad1d7b363908e68a5 to your computer and use it in GitHub Desktop.
Save ktakashi/21cad1d7b363908e68a5 to your computer and use it in GitHub Desktop.
Macro phasing
(import (except (rnrs) cons)
(for (only (rnrs) cons syntax-case lambda
display newline syntax) expand (meta 2)))
(define-syntax foo
(lambda (x)
(define-syntax expand-phase
(lambda (x)
(display (cons 1 2)) (newline)
#'#t))
(expand-phase)
#'#t))
(foo)
;; prints (1 . 2)
(display (cons 'a 'b)) (newline)
;; should be an error
#|
error:
Racket (plt-r6rs)
NMosh (Andre van Tonder expander)
Larceny (ditto)
ok:
Chez
Mosh (psyntax)
Ypsilon
Sagittarius
|#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment