[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Operators on functions
- From: "Pierre Chapuis" <catwell@...>
- Date: Wed, 20 Nov 2013 11:04:36 +0100
> 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