the point of selective importing

Georg Wrede georg.wrede at nospam.org
Wed Jul 12 02:57:11 PDT 2006


Regan Heath wrote:
> On Wed, 12 Jul 2006 01:03:16 +1200, Regan Heath <regan at netwin.co.nz> wrote:
> 
>> On Tue, 11 Jul 2006 15:56:44 +0300, Georg Wrede 
>> <georg.wrede at nospam.org>  wrote:
>>
>>> Bill Baxter wrote:
>>>
>>>> static import module.with.a.long.name.string;
>>>> alias module.with.a.long.name.string Str;
>>>
>>> import module.with.a.long.name.string as Str;
>>>
>>> This keeps "Str" and the module name and the word import on one 
>>> line,  making it hugely easier to grep for them.
>>
>>
>> Assuming the coder wasn't a 'half sane monkey on crack' you should be  
>> able to open the file in an editor, go to the top and do a 
>> search/find  on "Str", the first result should find it. Anything else 
>> is either bad  programming practice or a moderately rare case where 2 
>> things include  each other and so one uses the other before it's 
>> declaration.

Personally, I do a lot of grepping to find stuff in source trees. Mostly 
they are recursive greps, i.e., not done within an editor.

For an example, I might want to know with what names this 
"module.with.a.long.name.string" is imported in the tree. Of course I 
could create a two-line regexp for the search, but that's a lot of work. 
And I'd have to allow for a potential comment or empty line(s) in 
between, for all I know. :-(

But to a more important point, "module.with.a.long.name.string" is only 
written once. Maintenance gets a lot easier that way.

> In fact a good UI should be able to take you to the declaration of a  
> symbol with the press of a single button, like F12 in developer studio  
> does when you have browse info enabled.

I don't know of too many that good IDEs for D.



More information about the Digitalmars-d mailing list