[erlang-questions] Code/Hot/Loading
Jon Watte
jwatte@REDACTED
Mon Jan 16 18:31:38 CET 2012
Funs are always bound to the code they are initially loaded from. Only name
look-ups are affected by code loading AFAICT.
This has been a source of exceptions in our previous development, because
the first time you load new code, F is still valid, but the second time you
load new code, the old code is purged and F is now invalid. Any call to it
will generate an exception.
We ended up wrapping our needs for lambdas in a module with state instead.
Not the most elegant, but allows us to get "dynamic lambdas." If all you
need in the fun is module:function, you can use a tuple for that instead of
a fun.
Sincerely,
jw
--
Americans might object: there is no way we would sacrifice our living
standards for the benefit of people in the rest of the world. Nevertheless,
whether we get there willingly or not, we shall soon have lower consumption
rates, because our present rates are unsustainable.
On Mon, Jan 16, 2012 at 6:41 AM, Gokul Evuri <chandu.gokul138@REDACTED>wrote:
> so for instance
>
> f() -> 3.
> x() -> F = fun() -> f() end,
> A = f(),
> B = ?MODULE:f(),
> C = F().
>
> right after F hash been defined,
>
> a new version of code for f() is defined as follows
>
> f()-> threeand loaded.
>
> What would be the value of C.
>
> --
> *Gokul Reddy Evuri,*
> *IT Universitet **Göteborg**,*
> *Göteborg,*
> *Sverige.*
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120116/72194d04/attachment.htm>
More information about the erlang-questions
mailing list