From bc8369b25c3ce47befdb6296cf120c88febe32ec Mon Sep 17 00:00:00 2001 From: Danny Yoo Date: Fri, 12 Aug 2011 12:48:42 -0400 Subject: [PATCH] starting to work on resources --- lang/base.rkt | 11 ++++++++--- lang/kernel.rkt | 22 ++++++++++++++++++++-- resource/compile-time.rkt | 21 ++++++++++++++------- 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/lang/base.rkt b/lang/base.rkt index 23a920c..9c5e3cf 100644 --- a/lang/base.rkt +++ b/lang/base.rkt @@ -1,5 +1,10 @@ #lang s-exp "kernel.rkt" -(provide (all-from-out "kernel.rkt") - #;(all-from-out "private/list.rkt")) + +(provide (except-out (all-from-out "kernel.rkt") + ) + ;;(all-from-out "private/list.rkt") + ) + (require racket/private/modbeg - #;"private/list.rkt") \ No newline at end of file + ;"private/list.rkt" + ) \ No newline at end of file diff --git a/lang/kernel.rkt b/lang/kernel.rkt index 96d1186..30df770 100644 --- a/lang/kernel.rkt +++ b/lang/kernel.rkt @@ -61,7 +61,7 @@ e null #%plain-module-begin - #%module-begin + (rename-out [my-module-begin #%module-begin]) #%datum #%app #%top-interaction @@ -69,6 +69,7 @@ module define define-values + let-syntax let-values let*-values define-struct @@ -433,4 +434,21 @@ symbol->string (error 'set-car! "Not available outside JavaScript context.")) (define (set-cdr! x v) - (error 'set-car! "Not available outside JavaScript context.")) \ No newline at end of file + (error 'set-car! "Not available outside JavaScript context.")) + + + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +(define-syntax (my-module-begin stx) + (syntax-case stx () + [(_ body ...) + (with-syntax ([(expanded-body ...) + (local-expand #'(body ...) + 'module-begin + #f)]) + (syntax/loc stx + (#%module-begin expanded-body ...)))])) \ No newline at end of file diff --git a/resource/compile-time.rkt b/resource/compile-time.rkt index c0956a9..fe3c414 100644 --- a/resource/compile-time.rkt +++ b/resource/compile-time.rkt @@ -11,12 +11,19 @@ ;; file-resource: ;; -(define-for-syntax (file-resource stx) +(define-syntax (file-resource stx) (syntax-case stx () [(_ path) - (syntax/loc stx - (let-syntax ([compile-time-code - (lambda (stx) - (displayln "at compile time") - #'(void))]) - (resource path)))])) + (let ([dontcare + (syntax-local-lift-expression #'(begin + (begin-for-syntax + (printf "Compile time code executing")) + (void)))]) + (syntax/loc stx + (let-syntax ([compile-time-code + (lambda (stx) + (printf "compile time code executing\n") + #'(void))]) + (begin + ;;dontcare + (resource path)))))]))