On Wed, Feb 15, 2017 at 02:18:48PM -0800, H. S. Teoh via Digitalmars-d-learn
wrote:
[...]
> Try this:
>
> auto debugPrint(string expr)() {
> writeln(expr);
> return mixin(expr);
> }
>
> string myCall = debugPrint!`someFunction(1, "hello")`;
[...]
OTOH, that won't work with local variables (it'd only print the variable
names, not the values). Presumably you'd also want to print the
variables too. So perhaps something like this instead:
auto debugPrint(alias fun, A...)(A args) {
writefln("%s(%(%s, %))", __traits(identifier, fun), [args]);
return fun(args);
}
string arg = "hello";
string myCall = debugPrint!someFunction(1, arg);
T
--
I see that you JS got Bach.