On Tuesday, 23 February 2016 at 10:16:43 UTC, Ola Fosheim Grøstad wrote:
On Tuesday, 23 February 2016 at 07:46:08 UTC, Era Scarecrow wrote:
If | effectively does the same as . (at least that's the impression I get, maybe I'm totally wrong), what benefit does it give other than confusing or obfuscating code?

It doesn't confuse or obfuscate code, on the contrary, it brings clarity and makes the code more legible.

You know, i remember that in C there was a dereferencing symbol, it was ->, and that was thrown out for UFCS as well as simplicity.

c->x and c.x were basically the same. Why not use -> instead of | ?

That would be fun wouldn't it. To borrow from w0rp's post earlier as I don't do this much.

x.map!(...).filter!(...).reduce!(...)
x.map!(...)|filter!(...)|reduce!(...)
x.map!(...)->filter!(...)->reduce!(...)

Honestly looking at them side by side, I don't like |, -> is almost preferable except I sometimes don't hit the > and have to re-edit it, unlike using ., but that's a minor gripe there.

Hell why not extend to the rest of the operators? Don't forget C++'s iostream pushes using very specific low level operations to do weird things.

x.map!(...)>>filter!(...)>>reduce!(...)
x.map!(...)<<filter!(...)<<reduce!(...)
x.map!(...)^filter!(...)^reduce!(...)
x.map!(...)-filter!(...)-reduce!(...)
x.map!(...)+filter!(...)+reduce!(...)
x.map!(...)&filter!(...)&reduce!(...)
x.map!(...)*filter!(...)*reduce!(...)
x.map!(...)!filter!(...)!reduce!(...)
x.map!(...)~filter!(...)~reduce!(...)
x.map!(...)%filter!(...)%reduce!(...)

Why stop there?

x.map!(...)&&filter!(...)&&reduce!(...)
x.map!(...)||filter!(...)||reduce!(...)
x.map!(...)::filter!(...)::reduce!(...)
x.map!(...)=>filter!(...)=>reduce!(...)
x.map!(...)++filter!(...)++reduce!(...)
x.map!(...)--filter!(...)--reduce!(...)
x.map!(...)<=>filter!(...)<=>reduce!(...)
x.map!(...)<>filter!(...)<>reduce!(...)
x.map!(...)>=<filter!(...)>=<reduce!(...)
x.map!(...)><filter!(...)><reduce!(...)
x.map!(...)!!filter!(...)!!reduce!(...)
x.map!(...)~~filter!(...)~~reduce!(...)
x.map!(...)%%filter!(...)%%reduce!(...)

I still stand by that _unless_ it shows it really improves it somehow, or adds something vital that it shouldn't be there.

Reply via email to