Doubt about funs
Francesco Cesarini
cesarini@REDACTED
Tue Feb 20 18:35:50 CET 2001
In Funs of the type {Mod, Fun}, arity must not be known at compile time
(As the function is exported in another module), and can thus be derived
during run time when the fun is called. (As other people have
mentioned, through the arity in the call, e.g. Fun(A,B)). Calling a non
existing exported function would then result in a run time error.
Funs of the type fun function/2 however need the arity specified as they
are local calls. Checks for the existence of local function are done at
compile time, there of, the arity must be stated.
Regards,
Francesco
Paulo Ferreira wrote:
>
> Well, here is my doubt:
>
> Taken fom the Erlang Extensions doc:
>
> "We can also refer a function defined in a different module with
> the following syntax:
>
> F = {Module,FunctionName} "
>
> In this case, how does Erlang gets the correct function, if
> in the module are several functions, with the same name
> but with different arity ?
>
> I know it gets the correct function, at least in the same module,
> because I tested it.
>
> Thanks
>
> Paulo Ferreira
>
> ------------------------------------------------
> Paulo Ferreira paf@REDACTED
--
Francesco Cesarini
Erlang/OTP consultant
Cellular: INT+44-7776 250381
ECN: 832-707192
http://welcome.to/cesarini.consulting
More information about the erlang-questions
mailing list