scala (was checksum for distributed debugging?)

Ulf Wiger (AL/EAB) ulf.wiger@REDACTED
Fri Dec 9 09:16:07 CET 2005


Happi wrote:

>   If you have the time to read half of it you have too much
>   time on your hands. )

No comment. (:

> Currently there is no real support for code updates in Scala, 
> but this might not be as big a problem as one might suspect.
> The hot code replacement is a cool feature of Erlang but it 
> has some shortcomings. There is no automatic way to update or 
> even detect changes in data structures.

Actually, there is... sort of.

I have the following code in my (not yet released)
updated plain_fsm.erl:

%%% @spec hibernate(M::atom(), F::atom(), A::[IntState]) ->
NEVER_RETURNS
%%%
%%% @doc Virtual function used to wrap a call to the BIF
erlang:hibernate/3.
%%% <p>This function cannot be called directly, but translates to the
call
%%%
<code>erlang:hibernate(plain_fsm,wake_up,[data_vsn(),Module,M,F,A])</cod
e>
%%% where <code>Module:data_vsn()</code> and
<code>Module:code_change/3</code>
%%% are expected to exist (the parse_transform will add and export the
%%% function <code>data_vsn() -< 0</code>, if it doesn't already
exist.)</p>
%%% <p>The function <code>plain_fsm:wake_up/5</code> will begin by
calling
%%% <code>Module:data_vsn()</code>, and if it is the same as before,
simply
%%% call <code>apply(M,F,A)</code>. Otherwise,
<code>Module:code_change(OldVsn,
%%% IntState, hibernate)</code> will be called first. This allows a
plain_fsm
%%% behaviour module to be "bootstrapped" to a new version during
hibernation.
%%% </p>
%%% @end
hibernate(_M, _F, _A) ->
    exit(cannot_be_called_directly).

wake_up(OldVsn, Module, M, F, [S] = A) ->
    case Module:data_vsn() of
        OldVsn ->
            apply(M, F, A);
        _NewVsn ->
            {ok, S1} = Module:code_change(OldVsn, S, hibernate),
            apply(M, F, [S1])
    end.



/Uffe



More information about the erlang-questions mailing list