Re: defining module from macro

"Scott G. Miller" <[email protected]>
Newsgroups gmane.comp.java.sisc.user
Message-ID <[email protected]>
On Thu, Aug 17, 2006 at 06:23:42AM -0700, Dan wrote:
> It turns out that the error appears even without a
> macro; the following loads but doesn't sc-compile:
> 
> (begin
>   (module tmpmod (tmp)
>     (define (tmp) 1))
>   (module mod (f)
>     (import tmpmod)
>     (define (f x) x)))
> 
> Surely this is not a feature... It does compile in
> chicken, for instance.

The problem is that compile-file does not evaluate syntactic definitions 
as it compiles them, as "eval" in SISC does.  So, since that is one 
expression, it will attempt to perform the import when syntax-expanding 
it, even though tmpmod isn't defined until after the expression is 
*evaluated*.  If the two were not in the same expression there wouldn't 
be this problem.

> 
> On another note, is there a macroexpand function that
> doesn't insert random annotation stuff (so not
> sc-expand)? If there isn't, please add one. With all
> the problems that Scheme macros have (see my earlier
> question about meta and psyntax v. 6.9c), at least a
> two-pass compilation procedure (first expand, then
> compile) might be viable.

You can do this by turning off annotations, eg:

(emit-annotations #f)

To create an sc-expand that Just Works that way, use SRFI-39's 
parameterize (supported in SISC without any imports):

(define (syntax-expand expr)
  (parameterize ((emit-annotations #f))
    (sc-expand expr)))


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.