Re: Re: single SchemeUnit code base

Jens Axel Søgaard <[email protected]> Sun, 08 May 2005 12:03:55 +0200
Newsgroups gmane.lisp.scheme.plt.schematics
Message-ID <[email protected]>
Noel Welsh wrote:
> --- Andrew Wilcox <schematics-dev-1nkB91yrSd/a/[email protected]> 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



-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4
opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20