From 6a1b143f3f0b49d18d4e1c3d4b3de1e9fbfb3052 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Sat, 9 Jul 2016 17:32:08 -0700 Subject: [PATCH] add `strip-identifier-bindings` --- beautiful-racket-lib/br/syntax.rkt | 3 ++- beautiful-racket/br/demo/stacker.rkt | 8 ++++---- beautiful-racket/br/demo/stacker2.rkt | 6 +++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/beautiful-racket-lib/br/syntax.rkt b/beautiful-racket-lib/br/syntax.rkt index 73ca511..e8bac8d 100644 --- a/beautiful-racket-lib/br/syntax.rkt +++ b/beautiful-racket-lib/br/syntax.rkt @@ -1,7 +1,8 @@ #lang racket/base (require (for-syntax racket/base syntax/parse racket/syntax syntax/strip-context) syntax/strip-context racket/function racket/list racket/syntax br/to-string) -(provide (all-defined-out) (all-from-out syntax/strip-context)) +(provide (all-defined-out) (all-from-out syntax/strip-context) + (rename-out [strip-context strip-identifier-bindings])) (module+ test (require rackunit)) diff --git a/beautiful-racket/br/demo/stacker.rkt b/beautiful-racket/br/demo/stacker.rkt index c362753..defd7f0 100644 --- a/beautiful-racket/br/demo/stacker.rkt +++ b/beautiful-racket/br/demo/stacker.rkt @@ -4,14 +4,14 @@ (define (stacker-read-syntax src-path in-port) (define stack-args (port->list read in-port)) - (strip-context - (with-pattern ([(STACK-ARG ...) stack-args]) + (with-pattern ([(STACK-ARG ...) stack-args]) + (strip-identifier-bindings #'(module stacker-mod br/demo/stacker (push STACK-ARG) ...)))) -(define-macro (stacker-module-begin PUSH-STACK-ARG ...) +(define-macro (stacker-module-begin PUSH-EXPR ...) #'(#%module-begin - PUSH-STACK-ARG ... + PUSH-EXPR ... (display (first stack)))) (define stack empty) diff --git a/beautiful-racket/br/demo/stacker2.rkt b/beautiful-racket/br/demo/stacker2.rkt index 30f884c..ed0e1db 100644 --- a/beautiful-racket/br/demo/stacker2.rkt +++ b/beautiful-racket/br/demo/stacker2.rkt @@ -4,15 +4,15 @@ (define (stacker-read-syntax src-path in-port) (define stack-args (port->list read in-port)) - (strip-context - (with-pattern ([(STACK-ARG ...) stack-args]) + (with-pattern ([(STACK-ARG ...) stack-args]) + (strip-identifier-bindings #'(module stacker2-mod br/demo/stacker2 STACK-ARG ...)))) (define-macro (stacker-module-begin STACK-ARG ...) #'(#%module-begin (define stack-result - (for/fold ([stack null]) + (for/fold ([stack empty]) ([arg (in-list (list STACK-ARG ...))]) (push arg stack))) (display (first stack-result))))