faq update

Matthias Lang <>
Wed Oct 23 13:22:03 CEST 2002


Hi,

I'm going through the FAQ, mainly to update the links for R9. While I
was at it I felt it was time to fix a question about FUNs. Any
comments about this wording (or the facts!)?

<sect3><title>Do funs behave during a code change?<para>

        Yes and no. A function spawned via a fun can have its
        code changed and the old code can be purged without
        problems.
        <para>

        On the other hand, a bound fun will not be replaced.
        In the following example, the old verson of F is
        executed even after a code change:

        <screen>
        -module(cc).
        -export([go/0, loop/1]).

        go() ->
                F = fun() -> 5 end,
                spawn(fun() -> loop(F) end).

        loop(F) ->
                timer:sleep(1000),
                F(),
                cc:loop(F).
        </screen>

        This type of problem can be solved in the code_change/2
        function in the standard behaviours.

Matthias



More information about the erlang-questions mailing list