also `for*/splice`

pull/174/head
Matthew Butterick 6 years ago
parent 5733b102f3
commit 104baa0384

@ -118,20 +118,28 @@
(provide when/splice) (provide when/splice)
(define-syntax (when/splice stx) (define-syntax (when/splice stx)
(syntax-case stx () (syntax-case stx ()
[(_ COND BODY ...) [(_ COND . BODY)
(with-syntax ([SPLICING-TAG (datum->syntax stx (setup:splicing-tag))]) (with-syntax ([SPLICING-TAG (datum->syntax stx (setup:splicing-tag))])
#'(if COND #'(if COND
(with-handlers ([exn:fail? (λ (exn) (error (format "within when/splice, ~a" (exn-message exn))))]) (with-handlers ([exn:fail? (λ (exn) (error (format "within when/splice, ~a" (exn-message exn))))])
(SPLICING-TAG BODY ...)) (SPLICING-TAG . BODY))
(SPLICING-TAG)))])) (SPLICING-TAG)))]))
(provide for/splice) (provide for/splice for*/splice)
(define-syntax (for/splice stx) (define-syntax (for/splice stx)
(syntax-case stx () (syntax-case stx ()
[(_ ([ID SEQ] ...) . BODY) [(_ ([ID SEQ] ...) . BODY)
#'(when/splice #t (for/list ([ID SEQ] ...) (with-syntax ([SPLICING-TAG (datum->syntax stx (setup:splicing-tag))])
(when/splice #t . BODY)))])) #'(apply SPLICING-TAG (for/list ([ID SEQ] ...)
(SPLICING-TAG . BODY))))]))
(define-syntax (for*/splice stx)
(syntax-case stx ()
[(_ ([ID SEQ] ...) . BODY)
(with-syntax ([SPLICING-TAG (datum->syntax stx (setup:splicing-tag))])
#'(apply SPLICING-TAG (for*/list ([ID SEQ] ...)
(SPLICING-TAG . BODY))))]))
(provide when/block) ; bw compat (provide when/block) ; bw compat
(define-syntax-rule (when/block cond body ...) (define-syntax-rule (when/block cond body ...)

@ -1 +1 @@
1521242140 1521302544

Loading…
Cancel
Save