Arbitrary abbreviations in phobos considered ridiculous

Jonathan M Davis jmdavisProg at gmx.com
Fri Mar 9 16:16:01 PST 2012


On Friday, March 09, 2012 18:50:50 bearophile wrote:
> Jonathan M Davis:
> > I don't know what the current state of UFCS is.
> 
> I have found a possible problem in it, and probably there are some missing
> parts, but it's working well.
> 
> At first I didn't like it a lot because it's cheap syntax sugar that adds no
> new power and gives programmers more freedom to write different-looking
> versions of the the same code (and this is often bad).

Which is one of the reasons that I really don't like the idea. Sometimes it's 
nice with strings, but it creates inconsistencies, and stuff like 5.max(7) just 
seems insane. UFCS will give people more freedom and may help templates in 
some cases, but I think that it's a major step back for readibility in 
general.

> But I have soon
> found that it's able to make functional-style code more readable, because
> you write: x.foo().bar().baz().spam()
> 
> Instead of this, where my eye sometimes loses count of the nesting level:
> spam(baz(bar(foo(x))))

I must be in the minority in that I find chaining with UFCS to be _harder_ to 
read than the more traditional way. It just feels insanely backwards to me. 
But some people definitely seem to prefer the UFCS chaining. YMMV.

- Jonathan M Davis


More information about the Digitalmars-d mailing list