lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> On Sat, Apr 18, 2009 at 8:31 AM, steve donovan wrote:
>> Penlight is a set of pure Lua libraries designed to make some common
>> tasks easier and more standard.

The pl.operator names perhaps should resemble Lua metamethod names
(e.g. "lt" rather than "less").

Instead of (or in addition to) operator names like ops.mul, one could
have ops['a*b'] or ops 'a*b' containing the representation in Lua
code.  This is generalizable to things like ops 'a+b^2' via code
generation techniques [1] (with memoization above) and is an
alternative to placeholder expressions (e.g. _1 + _2^2).

This could also be used in the pl.test module, allowing asserteq(x,y)
to alternately be written as test(ops'a=b', x, y) and more generally
allow things like test(ops'a<b', x, y), possibly with shorthand
test('<', x, y).

[1] http://lua-users.org/wiki/ShortAnonymousFunctions