Getting symbol of current function?
angel
andrey.gelman at gmail.com
Fri Dec 7 16:45:00 UTC 2018
On Friday, 7 December 2018 at 14:56:22 UTC, Stefan Koch wrote:
> On Friday, 7 December 2018 at 10:51:38 UTC, Tomer Filiba wrote:
>> Is there some clever way to get the *symbol* of the current
>> function, given overloads? I want to log the current
>> function's arguments, but __FUNCTION__ et al only give me a
>> name, which resolves to the first overload. For instance,
>>
>> void f(int x) {
>> pragma(msg, "overload1",
>> Parameters!(mixin(__FUNCTION__)));
>> }
>> void f(int x, int y) {
>> pragma(msg, "overload2",
>> Parameters!(mixin(__FUNCTION__)));
>> }
>>
>> shows
>> overload1(int)
>> overload2(int)
>>
>> It would be awesome to have something like __FUNCTION_SYM__ or
>> so, which references the actual symbol.
>>
>> -tomer
>
> It'd be awesome to have symbol variables in general.
>
> I am currently looking into that :)
When you are at it, look also at the "name" of the current lambda
function, so that it can be called recursively.
More information about the Digitalmars-d
mailing list