the point of selective importing

Jari-Matti Mäkelä jmjmak at utu.fi.invalid
Tue Jul 11 17:50:36 PDT 2006


Derek Parnell wrote:
> 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. ;-)

Yup. No problem, I was not thinking clearly here. Better get some sleep
- it's already almost 4am here :)

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

This is clearly an ad-hoc solution and I also use it.

> Yes, there has to be a better (something that is less costly to write,
> read, and maintain) solution.
> 
>  import std.string alias str;
>  import std.regexp alias re;
>  import util.str alias utl;
>  . . .
>  re.find( ... );
>  . . .
>  str.find( ... );
>  . . .
>  utl.find( ... );
> 
> would do nicely, thank you.

Yay, this is exactly the same syntax I though about. I suppose we
totally agree now :)

-- 
Jari-Matti



More information about the Digitalmars-d mailing list