[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: [ANN] tamale-1.2 - Erlang-style pattern matching library
- From: Scott Vokes <vokes.s@...>
- Date: Thu, 23 Sep 2010 17:29:40 -0400
(I sent out the original announcement just before the mailing list
went down in August, and have since added a lot of features.)
I wrote a library to do Erlang-style pattern matching in Lua. Rather
than writing a series of nested ifs to test/switch on a table's
structure, you can just specify the table itself, possibly with
variable captures. Pattern strings are also supported.
It's implemented in pure Lua (tested with Lua 5.1.4), so it should be
quite portable, and it's reasonably efficient. It uses linear search
with various kinds of indexing, most notably on the first pattern
value (as in Erlang and Prolog). I tried more complicated strategies,
such as compiling the pattern spec into CPS, but the compilation
(which, being Lua, happened at runtime) took too long to justify
teh slight improvement the matching speed. Indexing is fast and
still quite effective.
For usage examples, see the README, API docs, benchmark, and test
suite. More documentation and a rockspec will come soon.
I hope it's useful!