[Issue 9857] UFCS for struct opCall
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Apr 2 13:34:04 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9857
--- Comment #5 from bearophile_hugs at eml.cc 2013-04-02 13:34:00 PDT ---
(In reply to comment #4)
> I'd even like typeof() to be usable with that trailing syntax, like sizeof, see
> Issue 4272
The U of UFCS means universal. And ctors too are functions. So it's expected.
This silly example of random bigint creation shows why they are handy in UFCS
chains:
import std.stdio, std.bigint, std.algorithm, std.random,
std.ascii, std.range, std.array;
void main() {
auto b1 = 20.iota.map!(_ => digits[uniform(0, $)]).array.BigInt;
b1.writeln;
}
Long UFCS chains are better written in columns, like in F# language:
auto b1 = 20
.iota
.map!(_ => digits[uniform(0, $)])
.array
.BigInt;
If struct ctors don't support UFCS you have to wrap everything in a BigInt, and
it gets harder to read:
auto b1 = BigInt(20.iota.map!(_ => digits[uniform(0, $)]).array);
And those columns look bad:
auto b1 = BigInt(20
.iota
.map!(_ => digits[uniform(0, $)])
.array
.BigInt);
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list