On Wed, Feb 15, 2017 at 10:07:22PM +0000, data pulverizer via 
Digitalmars-d-learn wrote:
> I'd like to convert a call to a string for debug printing purposes for
> example:
> 
> 
> ```
> import std.stdio : writeln;
> void someFunction(int x, string y){}
> string myCall = debugPrint(someFunction(1, "hello"));
> writeln(myCall);
> ```
> writes:
> someFunction(1, "hello")
> 
> 
> Does this functionality exists? If not how can I construct it? Please
> note that the call `someFunction(1, "hello")` should also be executed.
[...]

Try this:

        auto debugPrint(string expr)() {
                writeln(expr);
                return mixin(expr);
        }

        string myCall = debugPrint!`someFunction(1, "hello")`;


T

-- 
Klein bottle for rent ... inquire within. -- Stephen Mulraney

Reply via email to