"Global" imports vs scoped imports

Jeremy DeHaan dehaan.jeremiah at gmail.com
Sun Feb 9 17:26:16 PST 2014


On Monday, 10 February 2014 at 00:30:14 UTC, Jonathan M Davis 
wrote:
> 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


Awesome. Thanks for the information. I've found a few places I 
think it makes sense, but I was a little worried about doing it 
everywhere. Code bloat city.


More information about the Digitalmars-d-learn mailing list