Why I'm Excited about D

Idan Arye via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 8 02:24:09 PDT 2015


On Wednesday, 8 April 2015 at 08:35:52 UTC, ixid wrote:
> On Tuesday, 7 April 2015 at 19:46:07 UTC, Ary Borenszweig wrote:
>> On 4/7/15 3:34 PM, deadalnix wrote:
>>> On Tuesday, 7 April 2015 at 18:01:53 UTC, Ary Borenszweig 
>>> wrote:
>>>> On 4/7/15 2:16 PM, deadalnix wrote:
>>>>> On Tuesday, 7 April 2015 at 08:58:57 UTC, ixid wrote:
>>>>>> Or to be more consistent with UFCS:
>>>>>>
>>>>>> foreach (name; names.parallel) {
>>>>>>  name.writeln;
>>>>>> }
>>>>>
>>>>> no.please
>>>>
>>>> wat
>>>
>>> unreadable.is.ufcs.using.over
>>
>> Yes, I don't like "writeln" being used with UFCS, it's an 
>> abuse.
>>
>> My point is that every language has WATs :-)
>
> Why is it 'an abuse'? Do you special case any other functions 
> or is names.parallel unacceptable as well? Are longer chains 
> ending in writeln acceptable or do you insist in putting the 
> whole chain inside a parens writeln?
>
> name.reverse.writeln
>
> or
>
> writeln(name.reverse)
>
> or surely that would break your dislike of single UFCS 
> arguments so you should stick to:
>
> writeln(reverse(name))
>
> Which is proper yoda speak.

At the very least, put () after the writelne:

name.reverse.writeln();

Using the property getter style for a function used solely for 
it's side-effects kind of conceals what you are trying to do 
here...


At any rate, since UFCS allows you to choose the order your code 
will be read in, you should try give as much information as soon 
as possible:

`writeln(name.reverse);` - the first word is `writeln`, so I know 
it's a statement that's going to write something to stdout.

`name.reverse.writeln();` - the first word is `name`, so I know 
it has something to do with the name.

Decide which one to use based on the first impression you want 
people to get from that statement.


More information about the Digitalmars-d mailing list