variable as function name

Raimo Niskanen raimo@REDACTED
Thu Apr 21 08:48:22 CEST 2005

Well, that is just the way it is..., or rather:

The only functions you can skip the module name for are
local, imported and autoimported (e.g erlang:self/0).

The Variable() calling syntax should not behave differently
depending on what is imported in the calling context, 
therefore the Variable should contain both module and function;
arity is defined by the parenthesis expression. You can 
send Variable to another process (on another node) and there
other functions may be imported, or even autoimported.

The modern way is Variable contains a fun(), the ancient way
from when funs did not exist is Variable contains {Module,Function}
where Module and Function are atoms. Quite some gurus claim
{M,F} funs are a bad, bad thing and should be exterminated ASAP.

vances@REDACTED (Vance Shipley) writes:

> Why is is that I can do this:
>    1> T = time.
>    time
>    2> erlang:T().
>    {16,8,22}
> But not this?
>    3> T().
>    =ERROR REPORT==== 20-Apr-2005::16:08:12 ===
>    Error in process <0.45.0> with exit value: {{badfun,time},[{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]}
>    ** exited: {{badfun,time},
>                [{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]} **


/ Raimo Niskanen, Erlang/OTP, Ericsson AB

More information about the erlang-questions mailing list