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

Andras Georgy Bekes <>
Mon Aug 18 16:00:35 CEST 2008


> -define(FUNCTION, hd(element(2,element(2,catch erlang:error([]))))).
A safer solution (it has no side effects, unlike the above):

-define(FUNCTION,element(2,process_info(self(),current_function))).

I don't know if it's more expensive or not, but if it does matter, 
you're doing something wrong.

	Georgy



More information about the erlang-questions mailing list