"Global" imports vs scoped imports

Jonathan M Davis jmdavisProg at gmx.com
Sun Feb 9 16:29:56 PST 2014


On Sunday, February 09, 2014 19:18:05 Dicebot wrote:
> Usage of selective imports is also encouraged.

Not so much. At least, not right now. They don't work right and tend to cause 
symbol conflicts:

https://d.puremagic.com/issues/show_bug.cgi?id=314
https://d.puremagic.com/issues/show_bug.cgi?id=8667

Now, once they're fixed, I could see an argument for using them, but until 
then, I'd advise staying away from them - at least in library code where the 
modules that you're writing are likely to be imported by other modules; it 
won't matter so much if it's the module with main in it and nothing is 
importing it. Certainly, using them in something like Phobos is generally a 
bad idea at this point.

Personally, I'm not sure that I'd use them even once they're fixed unless I 
really only need one or two symbols out of the module, as it gets tedious 
otherwise, but I know that some people do really like the idea of making it 
very explicit which symbols are being used from a module being imported.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list