Reddit: why aren't people using D?

Ary Borenszweig ary at esperanto.org.ar
Mon Jul 27 08:50:02 PDT 2009


Andrei Alexandrescu wrote:
> Kagamin wrote:
>> Walter Bright 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?
>>>
>> Your view of the problem is too technical. Functions used to denote
>> arbitrary "actions", while properties are designed to simulate data
>> rather than functions: fields with minor logic concerning accessing
>> them, e.g. input validation.
> 
> I so don't get this. Yes, functions are used to denote arbitrary 
> actions. Some of these actions can set and get state. It is convenient 
> to benefit of some syntactic aid for those cases (e.g. make their use 
> look and feel like fields). So far so good. But as long as there is no 
> innate validation or enforcement from the compiler that for example you 
> setFoo(5) ensures that getFoo() will get you 5, we're only talking about 
> syntactic convenience. This is it: syntactic convenience. Nothing else.
> 
>> This got reflected in naming conventions
>> directing to name functions with verbs and properties and fields with
>> nouns.
> 
> Fine.
> 
>> Properties being implemented by functions is a technical
>> detail, which may change: the property logic can become declarative
>> or come in a form of type checking and be tested by caller, or most
>> probably it can be replaced by invariant altogether.
> 
> I don't understand this.
> 
>> All these
>> alternative solutions have their certain limitations or advantages,
>> but they effectively do the same thing as "functional" properties
>> without changing their semantics. 
> 
> And consequently this.
> 
>> That's why properties are not
>> functions.
> 
> This post had a negative effect on me: I now think properties are 
> functions even more than before.

I think the only way you and Walter can understand what a property is 
and what it is used for is to use for some time a language that 
implements them. For example C#. Then you'll say "that's nice" and would 
want to implement it in D.



More information about the Digitalmars-d mailing list