Import concerns revisited

Walter Bright newshound at digitalmars.com
Mon Jul 10 12:05:51 PDT 2006


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.

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.

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.



More information about the Digitalmars-d mailing list