[plt-scheme] Shadowing imported bindings

From: Bradd W. Szonye (bradd+plt at szonye.com)
Date: Fri Oct 24 14:03:54 EDT 2003

> Bradd W. Szonye wrote:
>> (That's not criticism of PLT Scheme -- just noting that another
>> implementation made different choices.)

Matthias Felleisen wrote:
> Criticism is perfectly fine. We put up PLT Scheme as if it were a
> theorem and we invite careful and critical deconstruction (search and
> destroy) so that we can improve it. Just a general remark.

Let me rephrase: "This is not criticism of the 'nyah, nyah, Scheme-48
does it better' variety." I was wondering why the two implementations
were different here, in a what-are-the-consequences way rather than a
this-is-my-favorite-language way.

And after thinking about it more, I realized that the example that
originally made me want shadowing would actually *break* in the presense
of shadowing.

Problem is, sometimes you want the new decl to shadow, and sometimes you
want to ignore it. If you're writing a custom + procedure, you want it
to shadow the version in the initial mzscheme language. If you're
writing a multipurpose language/library module, you want to *ignore*
your rebinding of #%module-begin when you include it as a "library"

So it's probably best that you need to do this explicitly. If you want
to rebind +, you write a new language (initial-import) module that uses
explicit provide-renaming to shadow the default procedure. If you want
to use a language module library-style, you use (require (all-except
lang-spec #%module-begin #%top #%app #%datum)).

Now I do think there are some opportunities for better syntactic sugar
in this area. It does get annoying to use all-except blah blah ... all
the time, and it's a bit tricky to pull in primitive-overrides from
several different libraries.
Bradd W. Szonye

Posted on the users mailing list.