Adding properties/members to base types?

Kirk McDonald kirklin.mcdonald at gmail.com
Wed Sep 5 16:55:38 PDT 2007


Bill Baxter wrote:
> Steven Schveighoffer wrote:
> 
>> "Kirk McDonald" wrote
>>
>>> This currently works only for the array types. It was proposed to 
>>> generalize it for all types.
>>
>>
>> Kirk,
>>
>> Thanks, that is where I read it.  For some reason I couldn't find it.  
>> I hope it does get added, but only for basic types/enums, because 
>> allowing it for classes/structs would confuse the hell out of me :)  
>> Not only would you have to look through class definitions/base 
>> classes, but also randomly placed functions to find out what the 
>> definition of some class property is.
> 
> 
> That makes me nervous too.  It's hard enough having to search up the 
> inheritance hierarchy to find out where 'bar' is implemented when you 
> run across "foo.bar()".  But if you also have to potentially examine 
> *every* import as well... oh boy.
> 
> Another option would be to make them non-importable.  So then you know 
> it's either defined somewhere in the inheritance chain or in the local 
> file.  But that would probably just lead to people working around it 
> using mixin(import(...)).
> 
> Apparently other languages have this feature though.  I'm curious how 
> they avoid the maintenance nightmare.
> 
> --bb

This is why I am a big, big fan of selective imports (and to a lesser 
extent static imports): You always know exactly what you are importing 
and from where.

-- 
Kirk McDonald
http://kirkmcdonald.blogspot.com
Pyd: Connecting D and Python
http://pyd.dsource.org


More information about the Digitalmars-d-learn mailing list