Import concerns revisited

John Reimer John_member at pathlink.com
Mon Jul 10 17:21:57 PDT 2006


In article <e8unve$2qjl$1 at digitaldaemon.com>, Lucas Goss says...

>> 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.
>
>I can see your concerns and after trying out some ideas I partly agree.
>
>I just wish I knew who broke the dam because I don't like this water 
>under the bridge. Having the FQN as default seems to be the best 
>solution as any keyword before import seems like a kludge. 


No, it's no kludge.  We do it with "private" and "public" already :P, so having
a keyword in front of import is a non-issue.  If one really doesn't like it
there, they can change the format like much of anything in a structured
language.  That's a style issue, not a language one.

Example using selective imports:

# with module1
#      import func1, Struct1, Class1;


See?  Just think of it differently.  In fact that's how I would likely do it to
represent the two different sections clearly. Maybe add () to the "with"
statement to make it consistent with D's use of "with"?

# with (module1)
#      import func1, Struct1, Class1;

Elegance is not impossible to attain. We just have to be willing to look for it.
Consistancy is perfectly attainable too.  We just have to be willing to avoid
tunnel vision.


>(1)
>import std.math.*;
>import std.stdio.writefln;
>import std.stdio.writef;
>
>While the list style is nice in that it's a little less typing, and the 
>static is somewhat nice in that it doesn't break existing things:


Why use '*'?  That unnecessary since the current import already does that.


>(2)
>static import math;
>import std.stdio : writefln, writef;
>


So you don't mind the "static" in front of import?


>The argument that a rename of the base library (in this case std.stdio) 
>would be a pain to update I don't think holds. A rename is a simple find 
>and replace, which most text editors do simply. The vertical layout of 
>the first for me is easier (in my opinion) to read, and anything before 
>import makes the statement more confusing (as in the static).


I'm having difficulty following what you are trying to say.

The argument holds very well still because we could make our editors do a whole
lot of things, but that doesn't make it right.  We're talking about making a
language clear and easy to understand.

-JJR





More information about the Digitalmars-d mailing list