anaphoric/acond.rkt
2016-04-08 12:16:33 +02:00

18 lines
425 B
Racket

#lang racket
(provide acond it)
(require anaphoric/it
racket/stxparam)
(define-syntax (acond stx)
(syntax-case stx (else)
[(_ [else . else-body])
#'(begin . else-body)]
[(_)
#'(void)]
[(_ [condition . body] . rest)
#'(let ([tmp condition])
(if tmp
(syntax-parameterize ([it (make-rename-transformer #'tmp)])
. body)
(acond . rest)))]))