lua-users home
lua-l archive

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


> math.exp( 1 )->cosh()->round( 7 )

On Tue, Jul 4, 2017 at 9:31 AM, Charles Heywood <vandor2012@gmail.com> wrote:
I personally feel that while it is nice, it'll lead to ambiguousness. Haskell does it nicely: functions with multiple arguments essentially "return" a new function, so `x y $ z 1` would be like z(1)(x(y))` (I think it was Haskell...). Because Lua has only one function call for multiple arguments, I feel it's a tad bit weird.

That example might mean x(y)(z(1)) instead.

If we have an arrow proposal, let's add a currying proposal too.

local exp1 = math.exp * 1

-- equivalent to:

local exp1 = function(...) return math.exp(1, ...) end

But if it's implemented in the Lua level, where a data structure stores math.exp with it's curried arguments, and no function call takes place until a "()" e.g. exp1(), then it'd be a lot more performant than implementing currying with closures.

> math.exp( 1 )->(math.log * 10)

math.log(10, math.exp(1))

May a better operator than "*" can be found. I don't like it as it is.