[dmd-internals] Why are there suddenly tons of deprecation messages about imports in Phobos?

Jonathan M Davis via dmd-internals dmd-internals at puremagic.com
Mon Feb 22 07:56:46 PST 2016


On Monday, February 22, 2016 09:59:31 Steven Schveighoffer via dmd-internals wrote:
>
> > On Feb 22, 2016, at 7:04 AM, Jonathan M Davis via dmd-internals <dmd-internals at puremagic.com> wrote:
> >
> > On Sunday, February 21, 2016 19:08:37 Steven Schveighoffer via dmd-internals wrote:
> >>
> >> The key comment in those PRs: https://github.com/D-Programming-Language/dmd/pull/5426#issuecomment-181589047
> >
> > Well, while I can see why from an implementation perspective, it makes sense
> > to say that when you have
> >
> > import foo.bar : baz;
> >
> > you haven't really imported the module, so foo.bar.baz isn't legit, and you
> > have to say baz, from a usability perspective, nobody is going to expect
> > that foo.bar.baz suddenly is just baz and not foo.bar.baz, because you
> > imported it with a selective imports.
>
> Like the comment says, however, what if you have a local foo symbol defined? The compiler is going to complain, or silently choose one (I think with the new lookup rules, it would choose the local module’s name).
>
> With Phobos, this isn’t strictly an issue, since we have no local symbols named std. But I could see lots of problems with other libraries.

In that case, using static imports makes sense. They're there to avoid name
conflicts when importing a module. But having a symbol be usable and yet not
being able to use its FQN is just plain weird. Given what was said about the
compiler implementation, I can understand why it would end up that way, but
it's very unintuitive, and personally, it makes it so that I'm not
particularly interested in using selective imports. I would not have
expected a symbol to ever lose its FQN. It's not like it changes where it
was declared based on how it was imported, much as the compiler
implementation likes to act that way sometimes.

- Jonathan M Davis




More information about the dmd-internals mailing list