2 ms·
> In every other language I have to think about whether to write op(arg1, arg2 ... argn) or arg1.op(arg2, ... argn) or "arg1 op arg2" In D these are interchang
by WalterBright 4y ago
> In every other language I have to think about whether to write op(arg1, arg2 ... argn) or arg1.op(arg2, ... argn) or "arg1 op arg2"
In D these are interchangeable: op(arg1, arg2 ... argn) or arg1.op(arg2, ... argn) which is called Universal Function Call Syntax. It works very nicely. It enables a Left to Right reading of stacked function calls:
a(b(c(d(1)))) becomes 1.d.c.b.a() which is a lot more readable.
- sokoloff 4y agoIf d takes two args, is there an inverted syntax as in “(1, 2).d.c.b.a” or must you do d(1, 2).c.b.a or something else?
- WalterBright 4y ago`1.d(2).c.b.a` and `d(1,2).c.b.a` both work