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

Simon simon.vanbernem at
Sat Oct 23 18:23:47 UTC 2021

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){
   return a + b;

called in the following way:

reproducible_function(5, 9);

the mixin OUTPUT_REPRO_CASE will output the exact same call. I 
can then take that code, paste it into the tests and tadaaaa - I 
have a repro case.

The only problem I have with this is that you still need to give 
the function as a template argument to OUTPUT_REPRO_CASE. In 
other cases, I have gotten around this by giving __FUNCTION__ as 
the default argument to that template parameter, but that doesn't 
work here because the mixin expands to something that calls 
ParameterIdentifierTuple. ParameterIdentifierTuple does not take 
a string as an argument, but needs the actual symbol (or an 
alias) to be passed.

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. With this, I could then change the call 
to just be:

int reproducible_function(int a, int b){
    return a + b;

More information about the Digitalmars-d-learn mailing list