Re: Convert call to a string

2017-02-15 Thread data pulverizer via Digitalmars-d-learn
On Wednesday, 15 February 2017 at 22:07:22 UTC, data pulverizer wrote: That's great, thanks both of you!

Re: Convert call to a string

2017-02-15 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Feb 15, 2017 at 10:58:42PM +, ag0aep6g via Digitalmars-d-learn wrote: > On Wednesday, 15 February 2017 at 22:34:22 UTC, H. S. Teoh wrote: > > auto debugPrint(alias fun, A...)(A args) { > > writefln("%s(%(%s, %))", __traits(identifier, fun), [args]); > >

Re: Convert call to a string

2017-02-15 Thread ag0aep6g via Digitalmars-d-learn
On Wednesday, 15 February 2017 at 22:34:22 UTC, H. S. Teoh wrote: auto debugPrint(alias fun, A...)(A args) { writefln("%s(%(%s, %))", __traits(identifier, fun), [args]); return fun(args); } string arg = "hello"; string myCall =

Re: Convert call to a string

2017-02-15 Thread H. S. Teoh via Digitalmars-d-learn
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")`; [...]

Re: Convert call to a string

2017-02-15 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Feb 15, 2017 at 10:07:22PM +, 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 = d

Convert call to a string

2017-02-15 Thread data pulverizer via Digitalmars-d-learn
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