[erlang-questions] about fun vs. functions schisofrenia

Bjorn Gustavsson bjorn@REDACTED
Fri Jan 11 13:47:35 CET 2008

Andras Georgy Bekes <bekesa@REDACTED> writes:

> If you want to store a reference to a function in the long term 
> (surviving module upgrades), store the module and function name. When 
> you want to use it as the argument of a higher-order function, use the 
> expression
> fun Module:Function/Arity
> to "convert" your function reference to a fun.

A fun defined as fun Module:Function/Arity *will* survive code reloading.
It has a different internal representation than a fun defined as fun Function/Arity.

So it is safe to store the fun instead.

Björn Gustavsson, Erlang/OTP, Ericsson AB

More information about the erlang-questions mailing list