Reddit: why aren't people using D?
Ary Borenszweig
ary at esperanto.org.ar
Thu Jul 23 12:45:42 PDT 2009
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.
More information about the Digitalmars-d
mailing list