[erlang-questions] Finding a way to get function name from local function reference

Steve Davis <>
Thu Jan 22 10:19:03 CET 2009


Hi Sergey,

Then... <phew!> I am pleased to have helped :)

Coming from Java I too was used to a large measure of reflection 
support. I think that perhaps it's inherent in the  compilation/bytecode 
of erlang that there's limits on this. e.g. to get full debugging info 
in erlang you must have a compiler switch set that saves abstract code 
with the Beam format.

For most purposes this "limitation" will be of no conseqence, of course, 
and I actually view this as an advantage, since it means that there is 
greater commercial protection for redistributed, compiled code (You can 
even protect the abstract code you save in the beam (the compile:file 
encrypt_debug_info option).

This, of course, is one rather small advantage amongst a veritable 
universe of advantages that Erlang has over Java et al.

/s

Sergey S wrote:
> Hello.
> 
>> Yes. I *completely* misread and misunderstood the question <redface>.
> 
> Hm... Your suggestion was helpful to me. I've rewritten the module for
> testing out performace of fuctions using apply as you suggested.
> Thanks.
> 
> Sources of the module itself and sample.erl illustrating how to use it
> can be found here: http://gist.github.com/50240
> 
> bm:funs/4 takes module name, list of function names (or name prefix
> which all functions to test begin with), arguments to pass and number
> of iterates. Then it tests them and fine prints sorted results:
> 
> 1> sample:bm().
> decompress_2..........1130 (1134) ms.
> decompress_1..........1500 (1531) ms.
> decompress_3..........1530 (1525) ms.
> 
> Of cource, it would be much better to have the possibility of using
> function references, but it looks like there is no way to get the
> names of them at runtime (in the general case).
> 
> --
> Sergey
> 




More information about the erlang-questions mailing list