From: <jen...@so...> - 2005-05-08 10:04:08
|
Noel Welsh wrote: > --- Andrew Wilcox <sch...@an...> wrote: >=20 >>SISC is quite flexible about modules and macros. Want to >>have a macro >>that expands into a module? Sure, no problem! I don't >>know enough >>about PLT yet to know what can be done in PLT. >=20 > As I understand it, a macro cannot expand into a module in > the PLT system. This is a tradeoff the module system makes > to gain other static properties (such as knowledge of all > bound identifiers). =20 True. There are at least two ways to get around this: Method 1 -------- Put module bodies in seperate files and utilize include. ; a.scm - plt (module a mzscheme (require (lib "list.ss")) (provide foo) (include "a-body.scm")) ; a.sisc - sisc (load "list.ss") (include "a-body.scm") ; a-body.scm - common (define (foo x) x) Method 2 -------- Since macros can't expand into modules in PLT keep the PLT source as is - and define macros in SISC that "remove" the PLT specific module constructs. (define-syntax module (syntax-rules () [(_ module-name language more ...) (begin more ...)])) (define-syntax define-ignored (syntax-rules () [(_) (begin)] [(_ name names ...) (begin (define-syntax name (syntax-rules () [(_ more (... ...)) (begin #t)])) (define-ignored names ...))])) ; module related (define-ignored provide require prefix all-except prefix-all-except renam= e require-for-syntax) ; error related (define-ignored raise-mismatch-error raise-type-error) Then add a macro (sisc-only body ...) that in PLT expand to (void) and in SISC expands to body ... in order to put the SISC specific stuff in the same files as the PLT source. Apart from the sisc-only macro this was how I cheated in math-repl. Method 1 seems cleaner to me though. --=20 Jens Axel S=F8gaard |