[erlang-bugs] A funny bug

Robert Virding <>
Fri Aug 23 12:24:17 CEST 2013


Most definitely safer! An interesting question is what happens if you do a receive in the closure. Do you see or not see the "current" message? Does the original receive see any messages removed by the closure? Etc If it is possible to do it then people will do it irrespective if you tell them not to. And they will complain if the undocumented behaviour is changed. :-)

So if a parametrized receive is added then something like a MS is to be preferred to a general closure.

Robert

----- Original Message -----
> From: "Erik Søe Sørensen" <>
> To: 
> Sent: Thursday, 15 August, 2013 3:41:08 PM
> Subject: Re: [erlang-bugs] A funny bug
> 
> On 02-08-2013 16:57, Ulf Wiger wrote:
> [snip]
> > So arguably, a way to parameterize receive *should* be available, and
> > *should* be documented. I'm not saying that prim_eval:'receive'/2 is that
> > very thing that should be documented, but it comes close enough that
> > Erlang wizards like Tony should not only be excused for playing around
> > with it, but should be *expected* to. ;-)
> An alternative "parameterized receive" method is this:
> 
> http://polymorphictypist.blogspot.dk/2011/10/dynamic-selective-receive-erlang-hack.html
> 
> (Disclaimer: self plug)
> 
> It takes a compiled match spec, like so:
> 
>      dyn_sel_recv:match_spec_receive(CMS, 1000)
> 
> which is presumably safer than allowing any closure to be called.
> 
> /Erik
> _______________________________________________
> erlang-bugs mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-bugs
> 


More information about the erlang-bugs mailing list