But I don't think it's much different from directly matching the record itself as shown by my previous mail.<div><br></div><div><br></div><div>Barco<br><br><div class="gmail_quote">On Tue, Nov 22, 2011 at 3:24 PM, Bengt Kleberg <span dir="ltr"><<a href="mailto:bengt.kleberg@ericsson.com">bengt.kleberg@ericsson.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">The old record is a tuple. Like this:<br>
<br>
code_change(_Old_version, State_name, {state, Item1, Item2}, _Extra ) -><br>
{ok, State_name, Data#state{item1=Item1, item2=Item2,<br>
newfield=something}.<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
bengt<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Tue, 2011-11-22 at 07:52 +0100, Barco You wrote:<br>
> What you mean is like this?<br>
><br>
><br>
> code_change(_OldVer, Statename, Data = #state{}, _Extra) -><br>
> {ok, Statename, Data#state{ newfield = Something}.<br>
><br>
><br>
><br>
><br>
><br>
> On Tue, Nov 22, 2011 at 2:38 PM, Bengt Kleberg<br>
> <<a href="mailto:bengt.kleberg@ericsson.com">bengt.kleberg@ericsson.com</a>> wrote:<br>
> Greetings,<br>
><br>
> The way it is done in our code (lots of it) is to match the<br>
> old record<br>
> as a tuple.<br>
><br>
><br>
> bengt<br>
><br>
> On Mon, 2011-11-21 at 16:51 +0100, Daniel Dormont wrote:<br>
> > Hello all,<br>
> ><br>
> > I have a gen_fsm module and would like to take advantage of<br>
> hot code<br>
> > deploy. The module uses a record (called "state") and the<br>
> new version<br>
> > of the module includes some new fields in the record. What<br>
> is a nice<br>
> > clean way to code the my_module:code_change function to deal<br>
> with<br>
> > this? Are there any good examples out there on the web?<br>
> ><br>
> > Note: for my purposes it would be sufficient to detect that<br>
> the state<br>
> > record is out of date, and terminate cleanly. BUT the<br>
> correct<br>
> > functionality of the terminate/3 function in my module<br>
> depends on the<br>
> > state data, and I would need it to complete cleanly and not<br>
> crash in<br>
> > this instance because there are other processes that depend<br>
> on this<br>
> > one and need to be notified properly of its exit. The issue<br>
> is that<br>
> > the state itself contains the data of which processes those<br>
> are.<br>
> ><br>
> > What's the best approach here?<br>
> ><br>
> > thanks,<br>
> > Dan<br>
> > _______________________________________________<br>
> > erlang-questions mailing list<br>
> > <a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
> > <a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
><br>
> _______________________________________________<br>
> erlang-questions mailing list<br>
> <a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
> <a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
><br>
><br>
><br>
<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</div></div></blockquote></div><br></div>