<!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 bgColor=#ffffff>
<DIV><FONT face="Courier New" size=2>
<DIV><FONT face="Courier New" size=2>Hi,</FONT></DIV>
<DIV><FONT face="Courier New" size=2>With help of the PLT-list I succeeded in
making flavoured or composable modules, as I call them. Thanks Matthias and
Scott! </FONT><FONT face="Courier New" size=2>I am afraid though, that I
dont fully understand what I am doing in the two lines marked with
<======.</FONT></DIV>
<DIV><FONT face="Courier New" size=2>Jos Koot</FONT></DIV>
<DIV> </DIV>
<DIV>; Definitions window</DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2>(module compose-module-body
mzscheme<BR> (provide (rename compose-module-body
#%module-begin))<BR> <BR> (define-for-syntax (reader
filename-string)<BR> (with-input-from-file (syntax-object->datum
filename-string) read-syntax))<BR> <BR> (define-for-syntax
(map-local-introduce stx)<BR> (map syntax-local-introduce (syntax->list
stx)))<BR> <BR> (define-syntax (compose-module-body stx)<BR>
(syntax-case stx ()<BR> ((_ (requirement ...) (syntax-requirement
...) filename-string ...)<BR>
#`(#%module-begin<BR> (require #,@(map-local-introduce
#'(requirement ...))) ; <======<BR>
(require-for-syntax #,@(map-local-introduce #'(syntax-requirement ...))) ;
<======<BR> #,@(map reader (syntax->list #'(filename-string
...))))))))</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face="Courier New" size=2>#| Usage:</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face="Courier New" size=2>(module <module-name>
compose-module-body<BR> (require-spec ...)<BR> (syntax-require-spec
...)<BR> <filename-string> ...)</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face="Courier New" size=2>From each file one single sexpr
(possibly a begin form) is read and inserted in the module.</FONT></DIV>
<DIV><FONT face="Courier New" size=2>The sexprs must be considered to form one
single module body.<BR> <BR>Examples:<BR>|#</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face="Courier New" size=2>(with-output-to-file
"part1.scm"</FONT></DIV>
<DIV><FONT face="Courier New" size=2> (lambda () (write '(provide syn)))
#;'replace)<BR>(with-output-to-file "part2.scm"</FONT></DIV>
<DIV><FONT face="Courier New" size=2> (lambda () (write '(define var "It
works!"))) #;'replace)<BR>(with-output-to-file "part3.scm"</FONT></DIV>
<DIV><FONT face="Courier New" size=2> (lambda () (write '(define-syntax syn
(syntax-rules () ((_) var))))) #;'replace)</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face="Courier New" size=2>(module example-1 compose-module-body
<BR> (mzscheme) (mzscheme)<BR> "part1.scm" "part2.scm"
"part3.scm")</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face="Courier New" size=2>(require example-1)<BR>(syn) ; --> "It
works"</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face="Courier New" size=2>(with-output-to-file
"wrong-part.scm"</FONT></DIV>
<DIV><FONT face="Courier New" size=2> (lambda () (write
'unbound-identifier)) #;'replace)</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face="Courier New" size=2>(module example-2
compose-module-body<BR> (mzscheme)
(mzscheme)<BR> "wrong-part.scm")</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face="Courier New" size=2>(require example-2) ; icon
wrong-part.scm::1: compile: unbound variable in module in:
unbound-identifier</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face="Courier New" size=2>#| Interaction window:</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face="Courier New" size=2>Welcome to DrScheme, version
370.6-svn21jul2007 [3m].<BR>Language: Textual (MzScheme, includes R5RS).<BR>"It
works!"<BR>icon wrong-part.scm::1: expand: unbound variable in module in:
unbound-identifier<BR>> </FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2>Clicking on the icon opens the erroneous
file. Very nice. |#</FONT></DIV>
<DIV> </DIV></FONT></DIV></BODY></HTML>