Omissible Parentheses...
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Sun Aug 2 09:10:30 PDT 2009
Robert Jacques wrote:
> On Sun, 02 Aug 2009 09:06:29 -0400, Chad J
> <chadjoan at __spam.is.bad__gmail.com> wrote:
>
>> Robert Jacques wrote:
>>> On Sat, 01 Aug 2009 16:00:52 -0400, Michiel Helvensteijn
>>> <m.helvensteijn.remove at gmail.com> wrote:
>>>
>>>> Robert Jacques wrote:
>>>>
>>>>> I like them too (a lot). I find they increase the clarity of my code
>>>>> (particularly function chaining).
>>>>
>>>> I think that when you find you need to use function-chaining, the
>>>> functions
>>>> (except possibly the rightmost) are often meant to be
>>>> properties/fields.
>>>> That's why they would look more natural without parentheses.
>>>>
>>>
>>> Nope. I meant _function_ chaining. This comment comes mostly from using
>>> std.string and std.algorithm, whose functions don't behave as fields.
>>> Both of these libraries show off the power you get from the flexibility
>>> of function call / property duality. I've also used toggle/flag setting
>>> methods in this way. It's concise, clean and very understandable.
>>>
>>
>> Interesting. I don't think I've seen this angle yet.
>>
>> Could you provide code examples, please?
>
> Here are two examples from a couple of days ago:
>
> auto data = (cast(string)std.file.read(filename)).chomp.split;
BTW now Phobos has
auto data = std.file.readText(filename).chomp.split;
Andrei
More information about the Digitalmars-d
mailing list