Reddit: why aren't people using D?
Walter Bright
newshound1 at digitalmars.com
Thu Jul 23 17:40:05 PDT 2009
Ary Borenszweig wrote:
> Walter Bright wrote:
>> Michiel Helvensteijn wrote:
>>> * 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.
Ok, but not having visible side effects is just a convention, one which
is apparently not enforced by languages with special property syntax.
A pure function, however, can be statically guaranteed to have no side
effects. So IDEs, etc., can regard as 'properties' any such methods
which take no arguments.
More information about the Digitalmars-d
mailing list