[erlang-questions] Finding a way to get function name from local function reference
Steve Davis
steven.charles.davis@REDACTED
Wed Jan 21 05:07:35 CET 2009
Hi Sergey,
I think you may find it easiest to use "apply"
apply(Module, Function, [Arguments)
/s
On Jan 20, 6:03 pm, Sergey S <ad.ser...@REDACTED> wrote:
> Hello.
>
> I'm going to write a simple benchmark utility taking function
> references and then writing results with corresponding function names.
>
> What I'm looking for is the way to get readable function name at runtime.
>
> Here is pseudo code:
>
> get_name(fun some_mod:some_fun/0) -> some_fun
> get_name(fun some_fun/0) -> some_fun
>
> I took a look at "erl -man erlang" to find out what I can use in this
> case. erlang:fun_info(Fun, name) seems useful but it works only for
> exported function references:
>
> % erlang:fun_info/2 will return the readable name: {name, some_fun}.
> That is what I want to get.
> erlang:fun_info(fun some_module:some_fun/0, name)
>
> But it doesn't work for local function references (I've checked):
>
> % Note that 'some_module' is omitted. This function will return
> something like {name,'-test/0-fun-0-'} which is incomprehensible to me
> erlang:fun_info(fun some_fun/0, name).
>
> With local function references I have to use something other... Is
> there a simple way to get the name of the function?
>
> --
> Sergey
> _______________________________________________
> erlang-questions mailing list
> erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions
More information about the erlang-questions
mailing list