On Monday, February 22, 2016 14:27:28 Brad Roberts via dmd-internals wrote: > On 2/22/16 1:40 PM, David Nadlinger via dmd-internals wrote: > > On 22 Feb 2016, at 22:20, Brad Roberts via dmd-internals wrote: > >> While I can understand and work with that definition, it's never been the > >> way I've thought of > >> selective import. I always thought of them as exactly like regular > >> imports with a filter applied. > >> IE, import this module, but just this set of symbols instead of all of > >> them. > > > > I haven't followed the other recent changes all too closely, but I'm under > > the the impression that > > they always behaved differently regarding overload/conflict resolution, and > > still do so right now. > > For example, `import a; import b : foo; foo();` would work even if `a` also > > contained `foo()`, while > > there would normally be a conflict without the selective import. > > > > This is not to say that I'm particularly fond of that difference, though. > > I'm just pointing out that > > what you mention has not been a good working model for how selective > > imports work for quite a long > > while now – the mismatch is not just a consequence of the latest changes. > > > > — David > > I understand and acknowledge that. However, in my cases (which I admit > aren't terribly significant) > it's worked out correctly. > > What I'm trying to say is how I've expected them to work. I really don't > think tacking on a filter > list should be changing the semantics. A lot of the time I start off with > just "import foo" and > then later trim that down to "import foo : sym1, sym2, etc" based on what I > ended up using. IMHO, > that change should be _trivially_ correct. And it's actually not given the > current (and past) > definition.
Yeah. Your understanding and usage matches how I've always thought about them and to some extent at least how they've worked (though the implementation has occasionally had some wonkiness to it that hasn't made it quite that smooth). But particularly given the implentation, the namespacing of imports gets a bit weird. What I would have normally expected would be that an import makes it so that you can use all of the symbols that it imports in the current scope - either with just their name or their FQN, and if there's a conflict, you're forced to use their FQN. Selective imports then just restrict which symbols get imported from a module (but don't change the semantics otherwise), and static imports are used for those cases where there would be too many symbol conflicts between two or more modules, and you need to force FQN to make it work cleanly. None of that way of thinking about really involves merging namespaces or anything like that. The implementation, on the other hand, seems to be merging lists of symbols together as if they were all in the same module when you import them, and that makes for a very different way for them to function - one that I don't find intuitive at all. - Jonathan M Davis _______________________________________________ dmd-internals mailing list [email protected] http://lists.puremagic.com/mailman/listinfo/dmd-internals
