Import concerns revisited

Lucas Goss lgoss007 at gmail.com
Tue Jul 11 04:32:54 PDT 2006


John Reimer wrote:
> In article <e8unve$2qjl$1 at digitaldaemon.com>, Lucas Goss says...
>>
>> 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.
> 

Point taken.

> ...
> # 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.
> 

I understand what you're saying, but I also get what Walter is saying. 
This is already mostly attainable with alias, except that additionally 
you want selective imports. However I fail to see what (great) value 
selective imports have.

> 
>> (1)
>> import std.math.*;
>> import std.stdio.writefln;
>> import std.stdio.writef;
>>
>> ...
> 
> Why use '*'?  That unnecessary since the current import already does that.
> 

In the line before that I was saying it would be nice if water wasn't 
already under the bridge, because then we could do FQN by default. If 
FQN was the default, then there would need to be a way to import 
everything. Sorry for not making that clear.

>> (2)
>> static import math;
>> import std.stdio : writefln, writef;
>>
> 
> So you don't mind the "static" in front of import?
> 

I was saying I like the first way and how it lays out as opposed to the 
second way. Sorry for not being clear enough. I don't like the static 
and I'm not even sure it's necessary.

>> 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.
> 

I was talking about the argument of renaming the library would cause a 
difficulty in updating the aliases. As far as making a language clear 
and easy to understand, I don't see much difference in clarity with:

import lib.longname.x;
alias lib.longname.x.func1 func;
alias lib.longname.x.Class1 class;

import lib.longname.y;
alias lib.longname.y.func1 func_extra;
alias lib.longname.y.Class1 Class_extra;

and

with (lib.longname.x)
	import func1 as func, Class1 as class;

with (lib.longname.y)
	import func1 as func_extra, Class1 as Class_extra;


They both seem to be pretty clear.

Lucas



More information about the Digitalmars-d mailing list