the point of selective importing

jcc7 jcc7_member at pathlink.com
Wed Jul 12 06:33:57 PDT 2006


In article <1wb7225zjf13v.1n8u9dwecz2a8$.dlg at 40tude.net>, Derek Parnell says...
>
>On Wed, 12 Jul 2006 02:51:08 +0300, Jari-Matti Mäkelä wrote:
>
>>> Consider the simple situation in Phobos
>>> 
>>>  std.string.find
>>>  std.regexp.find
>>>  internal.gc.gcx.find
>>> 
>>> then add the various other 'find' members in external libraries.
>> 
>> Ok, have to admit that's true. But do you really use them all in the
>> same module? 
>
>Apparently, as that's how I got the error messages. ;-)
>
>> If there's only a small amount of conflicting names, the
>> import syntax does not have to be so incredibly complex.
>
>Totally agree. Currently I'm using this sort of syntax ...
>
> import std.string;
> alias std.string.find str_find;
> alias std.string.replace str_replace;
>
> import std.regexp;
> alias std.regexp.find re_find;
> alias std.regexp.replace re_replace;
>
> import util.str;
> alias util.str.find utl_find;

I've written some code similar to this before. It worked, but it was wordy and
awkward. (And it seemed to break easily, but that was probably more due to
incompetent programming on my part than a weakness of D.)


> import std.string alias str;
> import std.regexp alias re;
> import util.str alias utl;

I really like that proposed syntax. (We don't /need/ new keywords, so we
shouldn't need to add new ones.) I can't believe that syntax would be hard for
Walter to add, so it should be added. It would be incredibly useful.


> . . .
> re.find( ... );
> . . .
> str.find( ... );
> . . .
> utl.find( ... );
>
>would do nicely, thank you.

Yes, I think that'd be really cool.

jcc7



More information about the Digitalmars-d mailing list