Import concerns revisited
Tom S
h3r3tic at remove.mat.uni.torun.pl
Mon Jul 10 15:27:20 PDT 2006
xs0 wrote:
> Tom S wrote:
>
>> Another downside is that, the selective import using the 'with'
>> construct only imports these symbols into the current scope, while
>> 'static import' allows you to access all symbols from the imported
>> module if you use a fully qualified name. This is as evil as the
>> "'private', yet not private" symbols in modules.
>
> While I support improving import (particularly allowing import of single
> symbols), I think you're exaggerating here. There is actually nothing
> wrong if all FQNs from a module are accessible (if private worked,
> anyway ;), as most all of the problems arise only with unqualified
> names.. In fact, some languages (e.g. Java) allow access via FQN without
> even specifically importing anything, and I never heard referred to that
> feature as evil before :)
Actually, i just wish D imports worked like in Python. Then
import foo.bar.baz;
foo.bar.baz.a = 1;
would be legal, while
from foo.bar.baz import b;
foo.bar.baz.a = 1;
would be illegal. As I see it, one of the points about using selective
imports is the ability to specify *exactly* what should be imported and
no more. I wouldn't like to get access to the whole module thru FQNs
just because I wanted a few symbols and were forced to use 'static import'.
--
Tomasz Stachowiak /+ a.k.a. h3r3tic +/
More information about the Digitalmars-d
mailing list