Import concerns revisited

Tom S h3r3tic at remove.mat.uni.torun.pl
Mon Jul 10 14:43:47 PDT 2006


Walter Bright wrote:
> D already has a lot of syntax in it. We should be very careful about 
> adding more; not every convenience should have its own syntactic sugar.

Hmm... then how did we ever get MatchExpressions ? Or the new delegate 
literal syntax ? It seems like it requires an army to convince you about 
new adding features even if they are as obvious as the extra arguments 
to assert.

We should be careful about adding more syntax, but we shouldn't be 
paranoid about it. I don't want to sound rude, but you seem to be 
totally ignoring all the fine points that long time D users have stated 
in the recent discussions. What is so terrible about adding more 
convenient ways to import modules, especially if they can ease project 
maintenance and increase code readability ? Sure, you have your 'static' 
import. There are a few problems with it though. First, probably least 
important aspect is its name. What does 'static' mean here ? The 
reluctance to make it any better ? *g*

Secondly, let's examine a sample usage of the proposed syntax:

with foo.bar.baz import a, b, c, d, e, f;


Using static import, it becomes:

static import foo.bar.baz;
alias foo.bar.baz.a a;
alias foo.bar.baz.b b;
alias foo.bar.baz.c c;
alias foo.bar.baz.d d;
alias foo.bar.baz.e e;
alias foo.bar.baz.f f;


You might consider it as 'not that bad'. But think about refactoring. 
Say, you need to change the module 'foo.bar.baz' to 'foo.x.y'. With the 
proposed syntax, you just do one simple change. With 'static import', 
well... many.
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.

You want to give 'static import' a try and see how it turns out ? Why 
don't you implement the proposal instead, call it 'DMD.experimental.163' 
and see if *this one* works or not ?


-- 
Tomasz Stachowiak  /+ a.k.a. h3r3tic +/



More information about the Digitalmars-d mailing list