Import concerns revisited

kris foo at bar.com
Mon Jul 10 14:18:07 PDT 2006


Walter Bright wrote:
> David Medlock wrote:
> 
>> Derek Parnell wrote:
>>
>>>
>>> I'm hope I'm not messing up Kris' words here but I think he is saying 
>>> that  we need to cut down on the amount of typing and reading people 
>>> *must* do  in a program. Keep it to a minimum. Try and work the 
>>> syntax so that the  common and mandatory things are short, easy, and 
>>> intuitive to do. Make the  unusual and 'special' things have more 
>>> detail in the syntax.
>>>
>>
>> I 100% agree.  The usual cases should be implicit, and the corner 
>> cases explicit.
> 
> 
> But *are* they the usual case? As far as I can tell, Python is the only 
> significant language that allows aliasing of import names (though the 
> Python manual calls it "binding"). (We'll set aside the C++ #define 
> trick as not a reasonable method.) I haven't seen it used in Python 
> code, though I admit I haven't seen much Python code.
> 
> That's why I suggest just trying it for a while. Kris' original concerns 
> are met with the combination of 'static import' (I know, I know, should 
> think of some better keyword combination) and 'alias'. Syntax changes 
> should be done conservatively - if there's an existing way to do it, it 
> has to be used a lot to justify special syntax for it.

Yes, most of us are sensitive to that also. But it needs to be traded 
off carefully against usage patterns. I suggest you take a look at 
Sean's extensive and carefully considered reponse from yesterday, and 
perhaps mine also, since you appear to have ignored everything stated in 
both judging by the above comment?

BTW: it's perfectly feasible to handle all requirements with no new 
keywords at all:

import lib.text.locale;

import lib.text.locale : locale;

import lib.text.locale.Date;

import lib.text.locale.Date : myDate;


> Kris brought up 'goto' - sure, we can do a 'while' loop with a goto, but 
> loops are so very, very common that special syntactic sugar for it has 
> proven to be a big win.

This comes across as thoroughly disingeneous. If you want a comparison, 
Walter, use your own comparison with the built-in regex?

As was pointed out, Regex is /very/ rarely used in the grand scheme of 
things. Whereas import is used multiple times in pretty much every 
single module. It would be a mildly positive sign if you'd at least 
acknowledge that fact?

I again implore you to revisit those posts, and the followup ones posted 
by Dave and the many others.


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


Recall the following:

1) the concept of modules and the usage thereof is considered a 
principal aspect of D, and

2) import is something used *several times* in pretty much every D module

Thus, the earlier question remains: Do you, or do you not, wish the safe 
approach for import to be easy and convenient to use, maintain, and 
understand at a glance?



More information about the Digitalmars-d mailing list