Am 19.01.2012, 21:53 Uhr, schrieb Jonathan M Davis <jmdavisp...@gmx.com>:
On Thursday, January 19, 2012 20:56:39 Marco Leise wrote:
I just came across some C++ code and came to the conclusion, that
properties and indexed access should not modify the structure. In other
words all my @property and opIndex will probably also by const. An
exception to that being caching and access counting.
I don't know why you came to that concluson. I don't agree at all.
Obviously,
you're free to do what you want with your code, but that seems overly
restrictive to little or no benefit. Properties can be both getters and
setters
for a reason. It would be horrible if all you had were getters.
- Jonathan M Davis
Ah, I meant to say that getters should not modify their object. When I see
"a = abc.x[i]" I would be a little surprised to find that it changes the
observable state of abc. The same goes for "a = b.length()". Now it is
clearer, isn't is? :p