Avoid newbie record redundancy?

Damien Katz <>
Sat May 27 22:34:01 CEST 2006


Is the following also acceptable, both functionally
and stylewise? I find this more readable, but most
code I see written uses the when clause and
is_record().

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

--- Andrew Lentvorski <> wrote:

> Stephen Han wrote:
> > 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.
> 
> Yes.  That's exactly what I wanted.
> 
> Thanks,
> -a
> 




More information about the erlang-questions mailing list