start begin-label experiment

This commit is contained in:
Matthew Butterick 2016-06-11 19:27:32 -07:00
parent 1391c2abae
commit 8135a722ee

View File

@ -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)