On 12/14/2016 02:22 PM, Timothee Cour via Digitalmars-d wrote:
What about simply this:
```
module foo;
{
import std.stdio;
void fun(File foo){}
}
{
import sd.range;
void foo(T) if(isInputRange!T){}
}
```
Walter proposed this as well. We found two problems with it: (a) it is
not clear that the import is effected only if the name is looked up; (b)
the common case is one import clause for one declaration, which makes
the code awkward. Either you have an indirection level to start with:
{
import std.range;
void foo(T) if(isInputRange!T)
{
... one extra indent already ...
}
}
or the horror of C++ namespaces:
{import std.range;
void foo(T) if(isInputRange!T)
{
...
}
}
The fact that C++ namespaces introduce scopes has been an unpleasant
mistake. Virtually all coding standards I've seen make
namespace-introduced scopes special in that they don't participate in
the usual indentation rules. Even special emacs and vi rules have been
devised for that. Something we can learn from.
Andrei