lua-users home
lua-l archive

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


> On Mon, Nov 18, 2013 at 7:20 PM, Dirk Laurie <dirk.laurie@gmail.com>
> wrote:
>
>> What would be a sensible mapping of operators to metamethods?
>
> Functional programing hacks are fun, but I think it's not sensible
> encourage using them in Lua. Functional thinking mixes poorly with mutable
> values, and Lua tables are designed to be used through mutation rather
> than functionally.

I tend to agree. *Some* functional ideas are welcome in Lua,
for instance I consider defining a map() function and using
it with pure functions (e.g. tostring) idiomatic. Same with
folds.

Going futher and playing with things like composition often
results in confusing and inefficient code.

It can be fun as an experiment though, for instance:
https://github.com/catwell/cw-lua/blob/master/lua-pipe/example.lua

-- 
Pierre Chapuis