[plt-scheme] difference between imported definition versus locally defined definitions?

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Apr 23 22:11:59 EDT 2007

At Mon, 23 Apr 2007 16:45:25 -0700, "Yin-So Chen" wrote:
> What is the difference with respect to imported bindings and local
> bindings?  I notice that imported binding cannot be expanded via #%top?

`#%top' always refers to a definition outside of a module.

> In syntax a define often gets expanded to (#%top . id) form, so how can I
> write
> #'(define local-id imported-id)
> Given that the above gets expanded to
> #'(define-values (local-id) (#%top . imported-id))

If I understand, you don't really want `#%top'. Instead, you want the
binding that `imported-id' would have if it appeared at the top level
of its enclosing module (or at the plain top level, if the definition
appears outside of a module).

There's no way to do that right now (I think).

In fact, if there was a way to do that, then depending on how it
worked, I think it might open a kind of security hole: a macro might
expand to `(let ([x ....]) .... (<untrusted-thing> x))' where the
enclosing module also defines a top-level `x' that is supposed to
remain private. If `<untrusted-thing>' turned out to be a macro that
find the module-top-level binding of `x', maybe it could get at the
private `x'. Or maybe the relevant operations could be defined to
prevent that sort of thing; I'm not sure.


Posted on the users mailing list.