[erlang-bugs] A funny bug

Erik Søe Sørensen ess@REDACTED
Thu Aug 15 15:41:08 CEST 2013


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



More information about the erlang-bugs mailing list