Do we want functions to act as properties, or merely omit parens for ufcs/chaining?

Craig Dillabaugh cdillaba at cg.scs.carleton.ca
Mon Jan 28 20:34:32 PST 2013


On Tuesday, 29 January 2013 at 02:54:44 UTC, Chad Joan wrote:
> On 01/28/2013 08:59 PM, Craig Dillabaugh wrote:
>> On Tuesday, 29 January 2013 at 00:56:41 UTC, Chad Joan wrote:
>>> snip
>>>
>>> The limitation this imposes is that
>>> void foo(int a) {...}
>>> void bar(int a, int b) {...}
>>> cannot be called in this way:
>>> foo = 2;
>>> 2.bar = 3;
>>>
>>> snip
>>
>> I have been following the properties discussion a bit and lack
>> the experience to really comment on much. However, looking at
>> your posting I couldn't help but ask one question.
>>
>> You state that not allowing at statement like:
>>
>> 2.bar = 3;
>>
>> is a 'limitation'. Was 'limitation' really the word you were
>> looking for?
>> I find such code rather baffling. Perhaps it has valuable uses
>> somewhere, which is why I am asking.
>>
>> It sort of reminds me of Python where you can do something 
>> like:
>>
>> ' '.join( list_of_strings )
>>
>> which is very cute and all, but the following, rather mundane
>> function call would do a better job of conveying to the reader
>> what is going on, using the same number of keystrokes:
>>
>> join( list_of_strings, ' ')
>>
>> Craig
>
> I mean limitation in the mathematical sense.
>
> It's a combination of syntax elements that are valid in current 
> D, but would no longer be valid if the D community were to 
> desire a properties solution that includes this condition.
>
> If no one is harmed by this limitation, then it is still a 
> "limitation", and also a /useful/ limitation.

Thanks. That is what I was hoping was the case. I was just
curious if perhaps such obscure looking code enabled certain
idioms that somehow made the language more powerful.


More information about the Digitalmars-d mailing list