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