C++ UFCS update

Dejan Lekic via Digitalmars-d digitalmars-d at puremagic.com
Fri Feb 19 08:18:12 PST 2016


On Tue, 16 Feb 2016 08:08:46 +0000, Ola Fosheim Grøstad wrote:

> On Tuesday, 16 February 2016 at 07:59:49 UTC, w0rp wrote:
>> Personally, I find this proposal for C++ to be laughable. It's like
>> hitch hiking from New York to California, and only getting as far as
>> Texas and calling it good.
>>
>> The great thing about our UFCS is the left-to-right chaining of
>> algorithms.
>>
>> x.map!(...).filter!(...).reduce!(...)
>>
>> It beats the Hell out of...
>>
>> reduce!(...)(filter!(...)(map!(...)(x)))
>>
>> This proposal will encourage non member functions, which is good, but
>> will never reach the "aha" moment D had which gave us UFCS chaining.
> 
> Ugh, that syntax is abusing the implied semantics of dot-notation;
> member-access. Better to have a pipeline operator.
> 
> Such syntax abuse is common in other languages too, so I don't get the
> "aha". It is more a case of "ugh, repeated mistake"...
> 
> Explicit extension methods is a much better alternative.


+1 !!

I *completely* agree with this. UFCS is OK in some places but not 
everywhere like people do lately. What you said about abusing the dot-
notation is on the spot. It is not uncommon nowadays to see D code that I 
have absolutely no idea what it does, because of UFCS. I have to go 
through each piece separated by dots to understand what it is...

-- 
Dejan Lekic
  ✉ dejan.lekic (at) gmail.com
  ➚ http://dejan.lekic.org


More information about the Digitalmars-d mailing list