Broken UFCS Sucks
Nick Sabalausky
a at a.a
Thu Oct 20 23:27:59 PDT 2011
Just need to vent a little about this...
This is very nice:
class Foo
{
string doSomething(string str)
{ return ...; }
void blah(int[] arr, string[] defines)
{
auto a = arr .filter!"a<10"() .map!"a*2"() .reduce!"a+b"();
auto b = defines.map!`"--define="~a`() .join(" ") .to!string()
.doSomething();
// ---- or ----
auto a = arr
.filter!"a<10"()
.map!"a*2"()
.reduce!"a+b"();
auto b = defines
.map!`"--define=" ~ a`()
.join(" ")
.to!string()
.doSomething();
}
}
...except for the fact it don't work. Instead, we do:
class Foo
{
string doSomething(string str)
{ return ...; }
void blah(int[] arr, string[] defines)
{
auto a = reduce!"a+b"( map!"a*2"( filter!"a<10"(arr) ) );
auto b = doSomething( to!string( join(map!`"--define=" ~
a`(defines), " ") ) );
// ---- or ----
auto a = reduce!"a+b"(
map!"a*2"(
filter!"a<10"(arr)
)
);
auto b = doSomething(
to!string(
join(
map!`"--define=" ~ a`(defines),
" "
)
)
);
// ---- or ----
// ..."make a bunch of useless temps" example omitted b/c I don't
feel like writing it...
}
}
Fucking butt-ugly. (Translation: Next-to-impossible to read.)
That's all I wanted to say. /transmission-end
More information about the Digitalmars-d
mailing list