[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Redefining define



Quoting Lauri Alanko:
> On Sat, Dec 08, 2001 at 06:36:18AM -0700, Matthew Flatt wrote:
> >  (module util mzscheme
> >     (define-syntax util-define ...)
> > 
> >     (provide (rename util-define define)
> >              (all-from-except mzscheme define)))
> 
> But this requires that util is used as the initial import instead of
> mzscheme? 

Yes, because I thought you were trying to define a new language in that
sense. 

If you just want to provide just `define', that's fine, too:

 (module util mzscheme
    (define-syntax util-define ...)

    (provide (rename util-define define)))

But naming the export `define' isn't likely to be that useful, since
(as you point out), a module in the `mzscheme' language won't be able
to import `util' (without a prefix or renaming).

> This is kind of icky, since then you can't use multiple
> modules with these sorts of redefinitions simultaneously, except of
> course by combining the needed modules into yet another module to use as
> the initial import.

Most modules provide forms that extend Scheme. Those modules tend to be
composable in an obvious way, because they all extend Scheme.

Other modules are meant to define a Scheme-like language where certain
forms are "overidden". In other words, they change Scheme. Those
modules aren't composable in any obvious way by their nature. By
writing a new module to use as the initial import (as you suggest), a
programmer can effectively tell the module system how to compose the
languages.

> I can understand that disallowing _any_ overlap between names in scope,
> even between the initial and required modules, is conceptually elegant,
> but it seems to have impractical consequences.

I think that the impractical consequences of allowing overlap are far
worse than those of disallowing it. I often accidentally import/define
a name twice; it's almost always a typo, and the other times it's a
design problem that must be resolved carefully.

I know --- annecdotes along are not compelling. But my view of
disallowing overlap is based on the way it fits into the larger design,
which makes it difficult to argue in favor of one particular decision.

> Perhaps I'll just stick to another name. :)

That's probably the right thing.

Matthew