[plt-scheme] Re: sxml.ss - Works on its own, but not in module

From: John Clements (clements at brinckerhoff.org)
Date: Wed Jan 16 15:12:02 EST 2008

On Jan 16, 2008, at 12:52 AM, Dmitry Lizorkin wrote:

> Hello John
>
>> it's also sort of a problem with the sxml package, AFAICT.
>
> I agree with you completely.
>
>> Would it be possible to fix the package so that this is no longer  
>> an issue?
>
> I would be willing to fix this; however, I need your hint on how to  
> handle such an eval-inside-a-package-issue in PLT module system.

I believe that the canonical answer is: this use of eval is untenable  
in PLT Scheme.  In particular, I observe that in PLT v4 (more  
specifically, 3.99.0.9) that I cannot compile your "foo.ss" file,  
because I get an error that bar:f is unbound, which is pretty much  
what I'd expect.  I'm willing to believe that this code works  
differently in version 371.

IIUC, the (paraphrased) Flatt-phrase for this is: "the top level is  
broken and can't be fixed." (Actually, I guess I'm channeling Greg  
Pettyjohn there, too.)  Essentially, this would rule out using eval in  
the way you describe, and perhaps rule it out entirely.

In this case, of course, you could just replace your definition of  
bar:g with (define bar:g bar:f), and get the desired result.

I understand that the SXML package runs on many platforms, and that  
making drastic changes just for PLT might not make sense.  However, I  
would be very surprised if it wasn't possible to rewrite the code so  
that
a) it didn't use eval, and
b) it still ran fine on all those other platforms.

I'm wrong all the time though, so I might be surprised.  Also, I'm not  
saying anything about the time required to make these changes.

Again, forwarding without permission to plt-scheme, where there are  
lots of people who can answer this kind of question far better than I.

John




> Below is the minimal complete example to reproduce the situation.
>
> Dmitry
>
>
> ;file bar.ss:
> (module bar mzscheme
>
> (define (bar:f)
>   1)
>
> (define (bar:g)
>   (eval '(bar:f)))
>
> (provide (all-defined)))
>
> -----------------
>
> ;file foo.ss:
> (module foo mzscheme
>
> (require (file "bar.ss"))
>
> (define test
>   (bar:g))
>
> (provide test))
>
> -----------------
>
> ;file foo-user.ss:
> ;(require (file "bar.ss"))  ; Have to require bar.ss as well
> (require (file "foo.ss"))
> (display test)



Posted on the users mailing list.