[Nickle] Artificial distinction between import and autoimport

Bart Massey bart at po8.org
Wed Feb 6 10:42:31 PST 2008

In message <87k5linhrm.wl%cworth at cworth.org> you wrote:
> On Sat, 02 Feb 2008 23:56:13 -0800, Bart Massey wrote:
> >                              But I'm not getting what you
> > propose to have your revised import or load do if their
> > namespace target already exists.  Should they replace the
> > namespace, or stop?  Both behaviors have sensible use cases
> > I described previously, so I'm not sure how to make it "just
> > work".  Perhaps you want load and import to behave
> > differently at the command prompt vs in a loaded file?
> I think I'd recommend dumping the "auto" prefix universally and
> recommend that programs use "import" and make that do the right thing
> there.

"Do the right thing."  Check. :-)

Let me try one more time to explain what's going on
currently, with some use cases, and see if I can make sense
of the proposed new world:

Current: load <filename>
New: load <filename>
As far as I know, nobody's proposing changing this at all.

Current: autoload <name>
  If namespace <name> is not in scope, try to load
  a file whose filename is constructed from <name>.
New: load name
  Same as current semantics.
I'm not sure whether it's important to anyone to get rid of
"auto" here, so feedback would be welcome.

Current: import <name>
  Bring all the names that are part of namespace <name>
  into scope, giving an error if <name> is not a namespace
  currently in scope.
Current: autoimport <name>
  If name does not exist, try to autoload <name>; if the
  autoload fails, give an error. If namespace <name> is now
  in scope, import <name>; otherwise give an error.
New: import <name>
  Becomes an alias for autoimport <name>?
It appears to me that this change is a dangerous one.  In
particular, if I typo the name of a namespace that I just
defined, or if I forget to load a file I meant to load, I
might get an error on import, or I might get the contents of
an appropriately named and namespaced file that happens to
be lying around---this could also be a security hole,
depending on the situation.

What's the advantage of getting rid of "auto", again?  Is it
just too ugly to live with?  I'll admit that it might not
have been the most fortuitous choice, but do we really hate
it enough to make it go away?

> As for the case of the command prompt where someone wants to reimport
> something that's being hacked on currently---that's the special case
> so it should get the more specialized name, and "reimport" seems to
> fit quite well.

It would be quite convenient to have a single reimport
command; I've added that.  (I also fixed a minor bug in
autoload / autoimport that no one ever noticed before.)

> If one wanted to do magic where "import" would actually mean
> "reimport" at the prompt, then that would be possible, (but it sounds
> a bit too DWIM for my tastes).

I agree---I've just called it "reimport".  It's a bit of a
misnomer, though, as you can use it to do the initial import
as well; it doesn't really care whether the namespace is
already in scope.


More information about the Nickle mailing list