Possible @property compromise
Jonathan M Davis
jmdavisProg at gmx.com
Tue Jan 29 17:23:26 PST 2013
On Tuesday, January 29, 2013 17:06:32 H. S. Teoh wrote:
> Why do you have to mark naked variables as @property? Isn't that
> redundant?
In order to restrict what you can do with it to the subset of operations that
you can do with a property function. In particular, taking its address would
need to be illegal, as that won't work with a property function (or if it did,
it would return a different type). It would be impossible to replace a normal
variable with a property function without risking breaking code, because there
are operations that you can normally do on a variable that couldn't possibly
be implemented with a function (such as taking its address). But if you mark
it to restrict what it can do, then you could swap it out with a function
later without the risk of breaking code (which is one of the main reasons for
having properties in the first place). @property doesn't currently do this, but
it could, and if we don't have something like that, then it'll never be safe
to swap variables and property functions.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list