diff --git a/beautiful-racket-lib/br/subscope.rkt b/beautiful-racket-lib/br/subscope.rkt index 36e05cd..d3d9674 100644 --- a/beautiful-racket-lib/br/subscope.rkt +++ b/beautiful-racket-lib/br/subscope.rkt @@ -2,18 +2,18 @@ (provide (all-defined-out)) (define #'(introduce-scope _color . _parents) - (replace-context #'_color - (with-syntax ([color #'_color] - [color-string (format "~a" (syntax->datum #'_color))] - [define:color (format-id #f "define:~a" #'_color)] - [id:color (format-id #f "id:~a" #'_color)] - [color-binding-id (format-id #f "~a-binding-id" #'_color)] - [color-binding-form (format-id #f "~a-binding-form" #'_color)] - [color-id (format-id #f "~a-id" #'_color)] - [module-name (generate-temporary)] - [parents (if (pair? (syntax->list #'_parents)) - (car (syntax->list #'_parents)) - (syntax->list #'_parents))]) + (with-syntax ([color #'_color] + [color-string (format "~a" (syntax->datum #'_color))] + [color:define (format-id #f "~a:define" #'_color)] + [color:id (format-id #f "~a:id" #'_color)] + [color-binding-id (format-id #f "~a-binding-id" #'_color)] + [color-binding-form (format-id #f "~a-binding-form" #'_color)] + [color-id (format-id #f "~a-id" #'_color)] + [module-name (generate-temporary)] + [parents (if (pair? (syntax->list #'_parents)) + (car (syntax->list #'_parents)) + (syntax->list #'_parents))]) + (replace-context #'_color #'(begin (module module-name br (require (for-syntax br/datum br/syntax)) @@ -22,13 +22,13 @@ (begin-for-syntax (define-scope color parents)) - (define #'(define:color _id-in _expr) - (with-syntax* ([id:color (shared-syntax (format-datum "~a:~a" #'_id-in color-string))] + (define #'(color:define _id-in _expr) + (with-syntax* ([color:id (shared-syntax (format-datum "~a:~a" color-string #'_id-in))] [color-binding-id (color-binding-form #'_id-in)] [color-id (color #'color-binding-id)]) #'(begin (define color-binding-id _expr) - (define-syntax id:color + (define-syntax color:id (syntax-id-rules () [_ color-id])))))) (require 'module-name))))) diff --git a/beautiful-racket-lib/br/syntax-scopes-test-3.rkt b/beautiful-racket-lib/br/syntax-scopes-test-3.rkt index 97d6d4d..a3d201a 100644 --- a/beautiful-racket-lib/br/syntax-scopes-test-3.rkt +++ b/beautiful-racket-lib/br/syntax-scopes-test-3.rkt @@ -4,18 +4,19 @@ (introduce-scope blue) (introduce-scope red) -#;(introduce-scope purple (red blue)) - - (define #'(double-x) (with-blue-identifiers (x) - #'(+ x x))) + #'(set! x (+ x x)))) + +(define #'(display-x) + (with-blue-identifiers (x) + #'(displayln x))) + +(blue:define x 42) -(define:blue x 50) -x:blue +blue:x -(define:red x 42) -x:red +(double-x) -(double-x) \ No newline at end of file +(display-x) \ No newline at end of file