How can I dump an expression into log and execute it
sigod via Digitalmars-d
digitalmars-d at puremagic.com
Sun Jul 13 05:55:29 PDT 2014
On Friday, 11 July 2014 at 01:35:41 UTC, Delorien wrote:
> Hi,
>
> I have a C macro, which takes an argument, log it and call a
> function.
> So, if I had a source code like this:
>
> {
> _logfx(x + 10);
> }
>
> the actual code would be
>
> DebugLog("x + 10");
> fx(x + 10);
>
> Can I make similar tricks in the D language?
>
> Thank you.
Something like this would be possible if one could get string
representation of a lazy expression:
```
void _logfx(lazy int expr)
{
DebugLog(expr.stringof); // currently it outputs `expr()`
fx(expr);
}
```
More information about the Digitalmars-d
mailing list