the point of selective importing

Carlos Santander csantander619 at gmail.com
Tue Jul 11 09:11:30 PDT 2006


Walter Bright escribió:
> John Reimer wrote:
>> And Walter, you particularly seem to be stirring this pot by 
>> repeatedly posting
>> misinformation.  We have several times demonstrated the difference 
>> between the
>> two systems.  If you don't understand what we are saying is different, 
>> please
>> ask us to clarify rather than adamantly stating in every post that 
>> there is
>> *nothing* different between the two.  The difference has been clearly
>> demonstrated more than once.  You seem to be refusing to admit it.
> 
> So I've apparently missed something. Please explain what the semantic 
> difference is.

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?)

====

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

-- 
Carlos Santander Bernal



More information about the Digitalmars-d mailing list