[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 04:04:17 PST 2016


On Sunday, February 21, 2016 19:08:37 Steven Schveighoffer via dmd-internals wrote:
>
> > On Feb 21, 2016, at 2:47 AM, Jonathan M Davis via dmd-internals <dmd-internals at puremagic.com> wrote:
> > Wow. All of the comments in the PRs that you guys linked to make this look
> > like quite a mess, even if we're ultimately better off. It does seem pretty
> > messed up to me though that you can't use a symbol's full import path when
> > you've imported it selectively. I would have expected to still be able to do
> > that, just not have access to any of the other symbols in the module that
> > it's in - unless they too were selectively imported.
>
> 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. I think that the normal expectation is
that

import foo.bar;

and

import foo.bar : baz;

are identical with regards to baz; they just don't import the rest of
foo.bar. So, the new behavior is going to be confusing, and a number of
folks have been pushing selective local imports as the way to do things for
a while, so a lot of folks are using them, and I fully expect that there are
plenty of cases where the imported symbol is then used via its full import
path for clarity. The number of deprecation messages in Phobos is a great
example of that.

So, from a usability standpoint, this aspect of the change definitely seems
negative. Personally, it encourages me to not do selective imports if
they're going to be picky about whether the full import path is used or not.

> A start to fix them: https://github.com/D-Programming-Language/phobos/pull/4015

Well, thanks for that. Given the number of deprecation messages, we
definitely have a lot of code to change. But I can't help think that we
shouldn't need to make the change.

- Jonathan M Davis



More information about the dmd-internals mailing list