[erlang-questions] How to get the line number of current executable code?

Bengt Kleberg bengt.kleberg@REDACTED
Tue Aug 26 08:58:22 CEST 2008


Greetings,

Building upon the suggestion made by Ulf Wiger this would probably work
(possible reasons for not working includes, but are not limited to, tail
calls):
-define(FUNCTION_THAT_CALLED, lists:nth(2, element(2,element(2,catch
erlang:error([]))))).


bengt


On Tue, 2008-08-26 at 03:34 +0400, 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?
> 
> Best regards,
> 
> Ahmed Al-Issaei
> 
> On Mon, Aug 25, 2008 at 10:57 AM, Mats Cronqvist
> <mats.cronqvist@REDACTED> wrote:
> > Ulf Wiger wrote:
> >> I should perhaps bring special notation to the smiley at the
> >> end of my message. (:
> >>
> >> Whether or not the solution is cool is surely a matter of
> >> taste - but I believe that the one who first came up with it
> >> was Mats Cronqvist, the champion of obfuscated Erlang
> >> code. (:
> >>
> >  thanks for the endorsement...
> >
> >  for the record, i have since moved on to using this:
> > -define(position,[process_info(self(),current_function),{line,?LINE}]).
> >
> >  sometimes adding this:
> > proplists:lookup(source,?MODULE:module_info(compile)).
> >
> >  mats
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> >
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list