Reddit: why aren't people using D?
Daniel Keep
daniel.keep.lists at gmail.com
Thu Jul 23 18:31:54 PDT 2009
Walter Bright wrote:
> 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.
That's true, but you haven't addressed the other side of it: property
setters.
Let me give you an example of where I think a few people are trying to
come from. In VB6, you could create custom ActiveX controls. In the
code for it, you could declare properties with getters and setters.
The nice thing was that because the IDE could tell the difference
between functions and properties, it could display these properties
automatically in the property sheet for each control.
With D, you would need to explicitly state which methods are properties
manually somehow; dunno how you would, though. Especially when you
consider subclassing and mixins.
More information about the Digitalmars-d
mailing list