Walter Bright wrote:
Michiel Helvensteijn wrote:
Properties. Your syntactic sugar:
int i = c.p; // int i = c.p()
p = i // c.p(i)
They can't do these things:
* No control over their use by class designer: ANY member function
with one
or zero parameters may be called using 'property syntax'. This is not a
good thing.
Why not? Seriously, what is the semantic difference?
Semantic difference: a property doesn't have *visible* side effects. If
you invoke it one hundred times, it should always return the same thing.
And nothing else in your program should change. So it's kind of like
pure functions.
I say "visible" because you might want to implement a property lazily.
But the logic remains inside your class and it's visible in the outside
world.