Avoid newbie record redundancy?

Stephen Han <>
Sat May 27 15:29:29 CEST 2006


Hi

I am not sure whether I understand your question or not but do you want
something like this?

match_queue(MasterQueue) ->
receive
   { msgPeerMaster, A } when is_record(A,rcdPeerMaster) ->
      match_queue(queue:in(A, MasterQueue));
   _ ->
      ?elog("HELP!~n", [])
    end.

regards,

On 5/27/06, Andrew Lentvorski <> wrote:
>
> This is almost certainly a newbie question.  I have the following code:
>
> match_queue(MasterQueue) ->
>    receive
>        {msgPeerMaster,
>         #rcdPeerMaster{returnSocket=Socket, masterIP=MasterIP,
> masterPort=MasterPort}} ->
>            QItem = #rcdPeerMaster{returnSocket=Socket, masterIP=MasterIP,
> masterPort=MasterPort},
>            match_queue(queue:in(QItem, MasterQueue));
>        _ ->
>            ?elog("HELP!~n", [])
>    end.
>
> Is it possible to still do the match on rcdPeerMaster while not
> unpacking and then repacking everything?  That seems like a lot of
> needlessly duplicated code.
>
> Thanks,
> -a
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20060527/aea89de0/attachment.html>


More information about the erlang-questions mailing list