Paste number 138905: | racket nested macro indentifier binding |
Pasted by: | dca |
When: | 8 years, 8 months ago |
Share: | Tweet this! | http://paste.lisp.org/+2Z6H |
Channel: | None |
Paste contents: |
#lang racket
(define-syntax (forever stx)
(syntax-case stx ()
[(forever body ...)
(with-syntax ([abort (datum->syntax #'forever 'abort)])
#'(call/cc (lambda (abort)
(let loop () body ... (loop)))))]))
(define-syntax (while stx)
(syntax-case stx ()
[(while test body ...)
(with-syntax (; abort* is accessible as ‘abort’
[abort* (datum->syntax #'while 'abort)])
#'(forever (let (; link the two bindings
[abort* abort])
(unless test (abort))
body ...)))]))
(define (g)
(while #t (abort)))
This paste has no annotations.