[erlang-questions] managing large records

Ulf Wiger ulf@REDACTED
Sun May 11 13:26:12 CEST 2008


You could try exprecs:

http://forum.trapexit.org/viewtopic.php?p=21790#21790

BR,
Ulf W


2008/5/11 Szabolcs Berecz <szabolcs.berecz@REDACTED>:
> Hi,
>
>  I have a record with a lot of fields which are updated nontrivially. I
>  tried to create a process for this task which looks like this:
>
>  -record(mm, {a=1,b=4,c}).
>
>  new() ->
>         loop(#mm{}).
>
>  loop(Mm) ->
>         receive
>                 {set, Field, Value} ->
>                         loop(Mm#mm{Field=Value});
>                 {get, Pid} ->
>                         Pid ! Mm,
>                         loop(Mm)
>         end.
>
>  But as you probably know, it doesn't work because it needs to now the
>  value of Field at compile time (or at least, that's what I have
>  concluded).
>  So, my question is: how would you solve the problem (lot's of fields,
>  almost random updates)?
>
>  Szabi
>
>  --
>  DRM: Digital Restrictions Management -- learn about the dangers at
>  http://www.defectivebydesign.org/what_is_drm
>  _______________________________________________
>  erlang-questions mailing list
>  erlang-questions@REDACTED
>  http://www.erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list