Re: Is there an alternative to "__FUNCTION__" that gives the actual function symbol and not the name as a string?

2021-10-24 Thread Imperatorn via Digitalmars-d-learn
On Sunday, 24 October 2021 at 14:05:35 UTC, Simon wrote: On Saturday, 23 October 2021 at 20:24:32 UTC, Tim wrote: [...] That worked! I needed to modify it a bit, since there is the "execution_count_to_log_reproduction_on"-template parameterto the enum. If I try to use that inside the token

Re: Is there an alternative to "__FUNCTION__" that gives the actual function symbol and not the name as a string?

2021-10-24 Thread Simon via Digitalmars-d-learn
On Saturday, 23 October 2021 at 20:24:32 UTC, Tim wrote: import std.traits, std.stdio; string generateLogCode(alias func)() { string code = "writeln("; code ~= "\"" ~ fullyQualifiedName!func ~ "(\""; foreach(i, param; ParameterIdentifierTuple!func) { if(i)

Re: Is there an alternative to "__FUNCTION__" that gives the actual function symbol and not the name as a string?

2021-10-23 Thread Tim via Digitalmars-d-learn
On Saturday, 23 October 2021 at 19:52:19 UTC, Simon wrote: Thanks for putting up with me! I tried a bunch and it seems like I left out too much code, because I can't get it working 100%. I didn't even know about the q{} syntax, so I didn't think the stuff I left out would matter, but when

Re: Is there an alternative to "__FUNCTION__" that gives the actual function symbol and not the name as a string?

2021-10-23 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 23 October 2021 at 18:23:47 UTC, Simon wrote: For debugging purposes, I have built a mixin that will, when declared inside a function, output code to the console that will reproduce the exact function call. Sounds like what you really want is

Re: Is there an alternative to "__FUNCTION__" that gives the actual function symbol and not the name as a string?

2021-10-23 Thread Simon via Digitalmars-d-learn
On Saturday, 23 October 2021 at 19:03:41 UTC, Tim wrote: On Saturday, 23 October 2021 at 18:56:48 UTC, Simon wrote: And I tried to use your suggestion like this: enum OUTPUT_REPRO_CASE(alias func = __traits(parent, {})) = "build the actual code stuff with"~fullyQualifiedName!func~" and so

Re: Is there an alternative to "__FUNCTION__" that gives the actual function symbol and not the name as a string?

2021-10-23 Thread Tim via Digitalmars-d-learn
On Saturday, 23 October 2021 at 18:56:48 UTC, Simon wrote: And I tried to use your suggestion like this: enum OUTPUT_REPRO_CASE(alias func = __traits(parent, {})) = "build the actual code stuff with"~fullyQualifiedName!func~" and so on"; Which doesn't work. In that case func seems to become

Re: Is there an alternative to "__FUNCTION__" that gives the actual function symbol and not the name as a string?

2021-10-23 Thread Simon via Digitalmars-d-learn
On Saturday, 23 October 2021 at 18:36:27 UTC, Tim wrote: On Saturday, 23 October 2021 at 18:23:47 UTC, Simon wrote: So what I am looking for then is the equivalent to __FUNCTION__ that evaluates to the actual symbol of the function instead of its name, so it can be used as a parameter to

Re: Is there an alternative to "__FUNCTION__" that gives the actual function symbol and not the name as a string?

2021-10-23 Thread Tim via Digitalmars-d-learn
On Saturday, 23 October 2021 at 18:23:47 UTC, Simon wrote: So what I am looking for then is the equivalent to __FUNCTION__ that evaluates to the actual symbol of the function instead of its name, so it can be used as a parameter to ParameterIdentifierTuple. You could use the following:

Is there an alternative to "__FUNCTION__" that gives the actual function symbol and not the name as a string?

2021-10-23 Thread Simon via Digitalmars-d-learn
For debugging purposes, I have built a mixin that will, when declared inside a function, output code to the console that will reproduce the exact function call. So, as an example, for the following function int reproducible_function(int a, int b){