import concerns (was Re: Historical language survey)
Carlos Santander
csantander619 at gmail.com
Sat Jul 8 07:37:35 PDT 2006
Kris escribió:
> In article <e8nq1e$16r$1 at digitaldaemon.com>, Walter Bright says...
>> Walter Bright wrote:
>>>>> What can also be done is extend the import declaration to allow the
>>>>> .'s to continue so that specific symbols can be imported.
>>>> Now that would be great. I believe selective-importing (as an option)
>>>> would be a boon in a number of ways ~ and would resolve this issue
>>>> quite elegantly.
>>> I like this one better, too.
>> There's another way - have a different kind of import declaration, say,
>> precede it with static:
>>
>> static import foo;
>>
>> which will make the symbols in foo available, but only if they are
>> explicitly qualified. Then one could access bar in foo by either:
>>
>> foo.bar();
>>
>> or:
>>
>> alias foo.bar bar;
>> bar();
>>
>> but not:
>>
>> bar(); // error, undefined symbol
>>
>> The advantage of this is it is a bit more flexible and more consistent
>> with the way the rest of D lookups work.
>
> Er, that really doesn't work at all. Please ignore what I said a few minutes ago
> regarding this option (I really should get some sleep instead).
>
> The problem here is that, for the proposed static imports, everything must be
> fully-qualified with the /original import name/, and that's just plain awful for
> long import names. The "import as" allows one to give it a nice short name
> instead.
>
But "static import" + "alias" would give us something closer to "import as" than
the current "import" + "alias". Taking Sean previous example, if you have:
module some.guys.fancy.sql;
class connection { ... }
In your module you could do:
static import some.guys.fancy.sql;
alias some.guys.fancy.sql sql;
And you either use "sql.connection" or "some.guys.fancy.sql.connection", but
connection wouldn't be available in the current namespace.
Now, I know it's more typing, it's two lines when you we could do it in one, but
at least it would be an improvement (IMHO).
> And, I still think the selective-import is the superior solution anyway.
>
> (I'd delete my earlier reply, but TBird is doing really wierd things with
> messages right now, and is basically hiding all my own posts)
>
>
--
Carlos Santander Bernal
More information about the Digitalmars-d
mailing list