On Thursday, 4 February 2016 at 15:33:41 UTC, Andrei Alexandrescu
wrote:
https://github.com/D-Programming-Language/phobos/pull/3971 --
Andrei
People one github were asking for a dump function so they could do
int a = 5;
dump!("a"); // prints "a = 5"
Here's a working version if anyone wants it but you have to use
it like
mixin dump!("a");
//------------------------------------------------
mixin template dump(Names ... )
{
auto _unused_dump = {
import std.stdio : writeln, write;
foreach(i,name; Names)
{
write(name, " = ", mixin(name), (i<Names.length-1)?", ":
"\n");
}
return false;
}();
}
unittest{
int x = 5;
int y = 3;
int z = 15;
mixin dump!("x", "y"); // x = 5, y = 3
mixin dump!("z"); // z = 15
mixin dump!("x+y"); // x+y = 8
mixin dump!("x+y < z");// x+y < z = true
}