lua-users home
lua-l archive

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

Vyacheslav Egorov wrote:
> KHMan wrote:
>> From the little I know or understand of lambda calculus, it's
>> about anonymous functions.
> One can use  Y Combinator to implement recursion using only anonymous
> functions.
> local function Y(f)
>  function rec(...) return f(rec, ...) end
>  return rec
> end
> local fac = Y(function(fac, n) if n == 1 then return 1 else return fac(n
> - 1) * n end end)
> In fact one can turn Y in purely anonymous function. It is expensive,
> but possible. See Wikipedia or some good old book (e.g. Essentials of
> Programming Languages) for more details.

Thanks, it looks interesting. After seeing the examples, it looks
(from the point of view of a non-math person) like there is no big
advantage to such syntax, as the simplest way has code that is
easiest to understand.

Shoehorning lambda calculus into Lua, I guess, can be done in
many, many different ways. A long-winded syntax is a net loss to
the programmer, I think, as the programmer has a bigger cognitive
load to handle in order to grok the code. A math-like syntax on
the other hand, will look more like a formula, but will have a
distinctly different syntax or smell to it.

>From the little Lisp code I have studied, lambda functions are
usually short and concise, and a cumbersome syntax, I think, might
hinder instead of help.

Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia