Adding properties/members to base types?

Bill Baxter dnewsgroup at billbaxter.com
Wed Sep 5 12:48:58 PDT 2007


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


More information about the Digitalmars-d-learn mailing list