Function calls
Steven Schveighoffer
schveiguy at yahoo.com
Thu Jan 28 13:09:11 PST 2010
On Thu, 28 Jan 2010 15:59:30 -0500, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
> Denis Koroskin wrote:
>> On Thu, 28 Jan 2010 20:28:17 +0300, Lars T. Kyllingstad
>> <public at kyllingen.nospamnet> wrote:
>>
>>> Steven Schveighoffer wrote:
>>>> On Thu, 28 Jan 2010 10:22:45 -0500, Adam D. Ruppe
>>>> <destructionator at gmail.com> wrote:
>>>>
>>>>> On Thu, Jan 28, 2010 at 11:47:45AM -0300, Leandro Lucarella wrote:
>>>>>> Andrei Alexandrescu, el 28 de enero a las 07:57 me escribiste:
>>>>>> > I need to put it for all front() and empty() declarations. By the
>>>>>> > way I decided that popFront() is not a property. I don't know why.
>>>>>>
>>>>>> Because it denotes an action?
>>>>>
>>>>> I don't think it is that simple - I see popFront; as an action all
>>>>> the
>>>>> same as popFront();
>>>> Whether you use parentheses or not, it's not a property. The
>>>> statement of Andrei is that he doesn't know why it's not a property.
>>>> The simple reason is because it's an action.
>>>> Now, does popFront; look like an action? Yes. But that is not the
>>>> case being disambiguated. It is collateral damage. Because the
>>>> compiler doesn't understand English, it can't know whether to
>>>> disallow popFront; any more than an ambiguous term like read
>>>
>>> ...or, as in Andrei's example, 'empty'. In Java you'd write
>>> isEmpty(), or even worse, getEmpty(). In D we now have the option of
>>> declaring it a property, with little chance of people thinking it
>>> actually empties anything.
>>>
>>> -Lars
>> Great explanation, very convincing!
>
> How about this:
>
> foreach (line; stdin.byLine()) { ... }
>
> vs.
>
> foreach (line; stdin.byLine) { ... }
>
> How do I choose?
byLine is a property. It is fetching a range on stdin.
-Steve
More information about the Digitalmars-d
mailing list