<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16481" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=ti>Say I have a module with an option for its tuning. This
option will be used both in the transformer and in the run time environment. For
example:</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2>(module a mzscheme<BR>;option used both in
transformer and run time environment<BR> (define-for-syntax option
1)<BR> (define option 1)<BR>;-----------------<BR> (define-syntax
macro-a<BR> (case option<BR> ((1) (lambda (stx) #'"the option
is 1"))<BR> (else (lambda (stx) #'"the option is not
1"))))<BR> (define proc-a<BR> (case option<BR> ((1)
(lambda () "the option is 1"))<BR> (else (lambda () "the option is
not 1"))))<BR> (provide macro-a proc-a))<BR>(require a)<BR>(macro-a) ;
--> "the option is 1"<BR>(proc-a) ; --> "the option is
1"</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face=tim>However, I dont find it elegant to have two definitions for
conceptually the same option. The standard solution would be:</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2>(module option mzscheme<BR> (define
option 1)<BR> (provide option))</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2>(module b mzscheme<BR>;option used both in
transformer and run time environment<BR> (require-for-syntax
option)<BR> (require option)<BR>;-----------------<BR> (define-syntax
macro-b<BR> (case option<BR> ((1) (lambda (stx) #'"the option
is 1"))<BR> (else (lambda (stx) #'"the option is not
1"))))<BR> (define proc-b<BR> (case option<BR> ((1)
(lambda () "the option is 1"))<BR> (else (lambda () "the option is
not 1"))))<BR> (provide macro-b proc-b))<BR>(require b)<BR>(macro-b) ;
--> "the option is 1"<BR>(proc-b) ; --> "the option is 1"
</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face=tim>But now the definition of the option is separated from the
module, which I dont like too much. So I came up with the
following.</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2>(module c mzscheme<BR>;option used both in
transformer and run time environment<BR> (define-for-syntax option
2)<BR> (define-syntax (transfer stx)<BR> (syntax-local-introduce
#`(define option (#%datum .
#,option))))<BR> (transfer)<BR>;--------------------------------------------------------<BR> (define-syntax
macro-c<BR> (case option<BR> ((1) (lambda (stx) #'"the
option is 1"))<BR> (else (lambda (stx) #'"the option is not
1"))))<BR> (define proc-c<BR> (case option<BR> ((1)
(lambda () "the option is 1"))<BR> (else (lambda () "the option is
not 1"))))<BR> (provide macro-c proc-c))<BR>(require c)<BR>(macro-c) ;
--> "the option is not 1"<BR>(proc-c) ; --> "the option is not
1"</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face=tim>This seems to do what I want, but it seems a little bit
tricky too. Can I trust the approach in module c, or is the approach in modules
a and b safer?</FONT><FONT face=tim><BR>Best wishes, Jos koot.</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><BR><FONT face="Courier New" size=2></FONT> </DIV></BODY></HTML>