Article: the feature that makes D my favorite programming language
H. S. Teoh
hsteoh at quickfur.ath.cx
Sat Jul 25 16:22:52 UTC 2020
On Sat, Jul 25, 2020 at 01:28:34PM +0000, Adam D. Ruppe via Digitalmars-d-announce wrote:
> On Saturday, 25 July 2020 at 11:12:16 UTC, aberba wrote:
> > Oop! Chaining the writeln too could have increased the wow factor. I
> > didn't see that.
>
> oh I hate it when people do that though, it just looks off to me at
> that point.
Me too. It gives me the same creepie-feelies as when people write
writeln(x) as:
writeln = x;
Actually, D's lax syntax surrounding the = operator gives rise to the
following reverse-UFCS nastiness:
// Cover your eyes (unless you're reverse-Polish :-P)! and don't
// do this at home, it will corrupt your sense of good coding
// style!
import std;
void main() {
writeln = filter!(x => x % 3 == 1)
= map!(x => x*2)
= [ 1, 2, 3, 4, 5, 6 ];
}
// Output: [4, 10]
T
--
Winners never quit, quitters never win. But those who never quit AND never win are idiots.
More information about the Digitalmars-d-announce
mailing list