From 8135a722ee41a94398f4bdf45909f1cc9eaeb84d Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Sat, 11 Jun 2016 19:27:32 -0700 Subject: [PATCH] start `begin-label` experiment --- beautiful-racket-lib/br/begin-label.rkt | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 beautiful-racket-lib/br/begin-label.rkt diff --git a/beautiful-racket-lib/br/begin-label.rkt b/beautiful-racket-lib/br/begin-label.rkt new file mode 100644 index 0000000..883247b --- /dev/null +++ b/beautiful-racket-lib/br/begin-label.rkt @@ -0,0 +1,27 @@ +#lang br +(require rackunit) +(provide (all-defined-out)) + +(define (syntax->source stx) + ;; reconstitute the source string by using srclocs + ;; magic goes here + stx) + +(define-macro (begin-label LABEL . EXPRS) + #'(begin + (define LABEL (syntax->source #'EXPRS)) + (provide LABEL) + (begin . EXPRS))) + +(begin-label + zing + (define (f x) + (+ x x)) + + (define (g x) + (* x x))) + +(display zing) + +(check-equal? (f 5) 10) +#;(check-equal? (g 5) 25) \ No newline at end of file