[erlang-questions] How to get the line number of current executable code?
Tue Aug 26 10:54:50 CEST 2008
Richard Carlsson wrote:
> 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.
there is no way to reliably get the name of the calling function.
it is true that the stack sometimes contain the name of the calling
it is not true that the only way to inspect the stack is by forcing an
i'm too lazy to write actual code, but try this in the shell;
<<_:F/binary,R:L/binary,_/binary>> =B, R end.
()43> S(BT,re:run(BT,"Return addr\\s[0-9a-z]+\\s\\(([^\\s]*)")).
clear as the day!
More information about the erlang-questions