Function calls

Bill Baxter wbaxter at gmail.com
Thu Jan 28 15:01:10 PST 2010


On Thu, Jan 28, 2010 at 2:49 PM, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
> Pelle Månsson wrote:
>>
>> On 01/28/2010 11:23 PM, Michiel Helvensteijn wrote:
>>>
>>> Andrei Alexandrescu wrote:
>>>
>>>> I agree. So where's the consensus? Things seemed so clear when people
>>>> were beaten with @property over their head.
>>>
>>> If I read the TLP correctly, @property seems not to be working correctly.
>>>
>>> @property (or any other notation marking property getters/setters) should
>>> be
>>> enforced. Functions that have it must only be invoked using property
>>> syntax. Functions that don't have it must be called with parentheses.
>>> That's the whole point. To give the designer of the class control over
>>> how
>>> it is used.
>>>
>>> The problem is people blurring the line between what's supposed to be a
>>> function and what's supposed to be a property, by abusing property syntax
>>> to invoke actions without parentheses.
>>>
>>> In reality, I believe there's not only a clear line between the two
>>> intentions, there's a demilitarized zone. You just need to enforce it.
>>> You
>>> can't have your cake and eat it too.
>>>
>>
>> I don't understand what any of this would improve. Is the byLine example
>> less readable without the ()? Is it more bug prone?
>>
>> The only thing achieved as I can see is that every class designer makes up
>> his own rules about which functions are property and which are not. If this
>> is somehow enforced, it will become a guessing game about how to call
>> no-argument functions. For what?

The "what" is the things listed in DIP4
(http://www.prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP4)
Particularly these issues:

int delegate() foo() {
	return delegate int(){ return 5; };
}

// Is this an int or a delegate?
auto x = foo();

// Is this a reference to foo, or a reference to the delegate returned by foo?
auto y = &foo;


--bb



More information about the Digitalmars-d mailing list