Why I'm Excited about D

Dicebot via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 8 06:42:49 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?

There are two main use cases for UFCS:

1) akin to extension methods in C#. It only ever makes sense to 
use UFCS syntax for cases where you would consider actually 
having method like this in used data type.

2) more readable syntax for functional style processing pipeline

There is no way anyone would ever add method called "writeln" to 
user data type and it is clearly not pipeline function. This is 
plain and disgusting abuse of the syntax, I am fully with 
deadalnix here.

For parallel it may be feasible if data set is actually intended 
for parallelization by design but I would personally consider 
that fishy too.

Omitting parens from function calls with side effects is another 
horrible sin but that is more of a personal taste thing.


More information about the Digitalmars-d mailing list