3 ms·
" It doesn't have pattern matching for selective receive, IIRC" So http://metalua.luaforge.net/ http://metalua.luaforge.net/ has an implementation of pattern m
by Avshalom 17y ago
" It doesn't have pattern matching for selective receive, IIRC"
So http://metalua.luaforge.net/ http://metalua.luaforge.net/ has an implementation of pattern matching as one of it's shipped examples. Do you know if ConcurrentLua could be used with pattern matching. or is it designed such that, as it stands, pm would be useless.
- silentbicycle 17y agoI don't think it does -- the receive function only takes a timeout[1]. If it did pattern matching, it'd probably take a table of potential patterns, or a table array of pattern->functions, or somesuch. After wondering before, I just checked the source. In message.lua, receive just takes an optional timeout. It'd be easy to have it take an optional function argument that tests each message in turn (since it's just a list of messages, modified in place), and returns a true if that message should currently be used. I'll test and submit a patch for it later. Not as flexible as pattern matching, but PM would be better off in the base language. As for integrating Metalua's PM with selective receive, I'm not sure. [1]: http://concurrentlua.luaforge.net/reference.html