Nested public imports - bug or feature?

jmh530 via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 13 11:47:14 PDT 2015


On Thursday, 13 August 2015 at 16:40:31 UTC, Dicebot wrote:
>
> Matter of scale. At some point of application size maintenance 
> cost become much higher than development costs - and problems 
> of name clashes become more important than any extra typing 
> annoyance.
>
> In my C++ projects such "using" abuse was normally banned.

I would add that it's not just C++. It is also common in Python 
to use the full name, albeit typically with an alias, e.g. import 
numpy as np. One benefit of this approach is that you can easily 
find every function using numpy in a file.

So, while I'm sympathetic with Jonathan's point about requiring 
the module being a little annoying if you're doing something 
small, I think you raise a good point about large projects. 
Nevertheless, others have already pointed out options for 
allowing the control that you need.

If you think that you should be able to re-define imports, then 
submit an enhancement request. I looked for any suggesting it, 
but didn't see anything.

I did see a few others related to imports that were interesting 
like allowing something like

import std {
      array, range;
}


More information about the Digitalmars-d mailing list