Doubt about funs
Ulf Wiger
etxuwig@REDACTED
Wed Feb 21 10:56:29 CET 2001
On Wed, 21 Feb 2001, Siri Hansen wrote:
>> Taken fom the Erlang Extensions doc:
>>
>> "We can also refer a function defined in a different module with
>> the following syntax:
>>
>> F = {Module,FunctionName} "
>>
>
>The documentation also says that you can use the test function/1 in a
>guard to check if a term is a fun. This test fails for the
>{Module,FunctionName} expression.
>
>Why?
Because Erlang has no way of telling if {M, F} is any ordinary tuple
of two atoms, or a reference to a specific function.
Erlang can, on the other hand tell the difference between a fun() and
a tuple. In older implementations of funs, it couldn't do that,
and you could create a 5-tuple that could pass for a fun(), until you
tried calling it.
/Uffe
--
Ulf Wiger tfn: +46 8 719 81 95
Senior System Architect mob: +46 70 519 81 95
Strategic Product & System Management ATM Multiservice Networks
Data Backbone & Optical Services Division Ericsson Telecom AB
More information about the erlang-questions
mailing list