DIP4: Properties

Daniel Keep daniel.keep.lists at gmail.com
Sat Jul 25 03:18:36 PDT 2009



Michiel Helvensteijn wrote:
> ...
> 
> It's a little better. But there's still ambiguity:
> 
> interface I {
>     int foo;
>     int opSet_foo(int);
> }
> 
> foo = 5; // which foo is used?
> 
> To fix that one, you need to report an error when both a var and a property
> of the same name are declared. Even though they don't have the same name in
> the interface.

I think this would NEED to be an error to keep the compiler from going
insane.

I don't see how this is appreciably different to a+b suddenly being
rewritten as a.opAdd(b).

> ...
> 
> I just don't understand this resistance against a dedicated property syntax.

You have to be careful: adding syntax increases the complexity of the
language.  Sometimes it's worth it, sometimes it isn't.

If we can do it without adding syntax and it's not too onerous then we
probably should.



More information about the Digitalmars-d mailing list