Possible @property compromise

Jonathan M Davis jmdavisProg at gmx.com
Tue Jan 29 18:30:50 PST 2013


On Tuesday, January 29, 2013 18:13:41 H. S. Teoh wrote:
> I'm not for throwing it out, actually. :) Just pointing out some
> problematic aspects of it.
> 
> One way to solve the '&' problem is to have the compiler lower that into
> a delegate that gives access to the setter/getter for that field. Then
> @property *would* indeed be a drop-in replacement for member variables.

But the type would be different. You wouldn't be able to do stuff like

int* p = &s.prop;

And what happens with a delegate is fundamentally different when you take the 
address of a variable. The property function may not even be returning a value 
associated with a variable. It could be calculated. I believe that you're 
trying to take the abstraction farther than is possible. All abstractions 
break at some point, and taking the address of a property is one place that 
property functions break as an abstraction for variables.

- Jonathan M Davis


More information about the Digitalmars-d mailing list