On 4/3/11, Nick Sabalausky <a@a.a> wrote: > I've always thought that we should be able to do something like this: > > template foo(int val) > { > enum foo = val.meta.argString; > } > static assert(foo!(2+3) == "2+3"); >
I wish we had some introspection to get the lines of code inside of a function. But it's still pretty cool that you can pass expressions to functions and automatically construct delegates. See here: import std.stdio; void main() { int x; foo(false, x = 5); assert(x != 5); foo(true, x = 5); assert(x == 5); } void foo(bool doit, int delegate()[] dgs ...) { if (doit) dgs[0](); } I wonder how many people know about this feature. I just bumped into it a few days ago while looking through the docs.