Import concerns revisited

Walter Bright newshound at digitalmars.com
Mon Jul 10 18:41:36 PDT 2006


kris wrote:
> 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;

I know. The ':' isn't even necessary.

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

The idea with regex came from Matthew's comments that when he wanted to 
do regex, he went with Ruby. Ruby and Perl have regex front and center, 
and they are heavily used in those languages. So, the fact that they are 
lightly used in D may be caused by them being *difficult to use* in D 
rather than because there is no interest in regex.

So I wanted to see why regex was so convenient in Ruby, and if that 
convenience could be migrated to D, thereby making D suitable for 
applications that did make heavy use of regex. Sort of "build it and see 
if they come", if you may.

Import is used everywhere. No argument there. But is selective import? 
Import with renaming? That is far less clear. If the latter capabilities 
are critical and would be ubiquitously used, why aren't they in C, C++, 
Java, Ruby or C#? They are in Python - but are they ubiquitously used in 
Python?

(On a personal style note, I wouldn't want to rename imports, especially 
if a lot of programmers are working on the project. I'd rather use FQN's 
so when I see foo.bar.abc, I know we're talking about the same thing.)

And I want to add once again, that we are not talking about a difference 
in power or capability. Just whether it is two statements, one of which 
uses existing D capabilities, or a sprinkle of syntactic sugar to 
combine them into one statement.

And lastly, to reiterate, it is not about how often import is used. It 
is how often selective import, or import with renaming, is likely to be 
used.



More information about the Digitalmars-d mailing list