the point of selective importing

Walter Bright newshound at digitalmars.com
Wed Jul 12 02:03:35 PDT 2006


Carlos Santander wrote:
> Here's what I've understood:
> 
> (Using Rioshin's examples)
> 
> You propose this:
> 
>     static import module.name;
>     alias module.name.foo bar;
> 
>     foo();    // illegal
>     module.name.foo();    // legal
>     bar();    // legal
> 
> With minor syntax variations, here's what others are proposing:
> 
>     with module.name import foo as bar;
> 
>     foo();    // illegal
>     module.name.foo();    // illegal
>     bar();    // legal
> 
> Notice how the FQN would be illegal.
> 
> (That's basically it, right?)

Yes, but I don't think it is a substantive difference.

> ====
> 
> Personally, I think both "static import" (or some variation of it), 
> selective import (with .. import ..) and import with aliasing (import .. 
> as ..) are needed. However, I don't like the "as" syntax: I think a 
> symbol would make it easier to read. My preferred choice would be =, but 
> like this:
> 
>     with a.b.c import f1 = foo1, f2 = foo2, f3 = foo3;
> 
> (Where f1, f2 and f3 are the aliased names.) I think the symbols provide 
> visual stops to understand clearly what's going on. That also makes me 
> dislike:
> 
>     import a.b.c d;
> 
> Because the space is easy to miss. IMO

Some good points.



More information about the Digitalmars-d mailing list