[erlang-questions] How to get the line number of current executable code?
Tue Aug 26 08:58:08 CEST 2008
Ahmed Ali wrote:
> Hi All,
> This discussion is interesting. Just wanted to know if it is possible
> to get the function that called current function. Is this possible?
The only way of doing that is to force an exception, and then look
at the stack trace. Something like this:
Trace = try throw(oops) catch oops -> erlang:get_stacktrace() end
However, due to tail call optimization in Erlang, you will not see
any functions in the list that were visited on the way but were exited
through a tail call.
More information about the erlang-questions