[erlang-questions] Function name macro (the counterpart of ?MODULE)

Attila Rajmund Nohl <>
Mon Dec 21 21:09:49 CET 2009


2009/12/21, Ciprian Dorin, Craciun <>:
>     Hy all!
>
>     Maybe this question has been asked a thousand times, but please
> forgive and bare with me just one more time... :)
>
>     So as predefined macros we have ?MODULE, ?FILE, and ?LINE... But
> there is no ?FUNCTION (that should give me the current function name).
>
>     Now my question is: why isn't there any such macro? (I would guess
> that having such a macro is not so complicated...) And what can I do
> to obtain a similar functionality?

I haven't tested, but you can try something like this:

catch throw x,
[{_, Fun, _} | _] = erlang:get_stacktrace().


More information about the erlang-questions mailing list