lua-users home
lua-l archive

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




On 06/08/16 05:30 PM, Sean Conner wrote:
It was thus said that the Great Soni L. once stated:
On 06/08/16 06:19 AM, Tim Hill wrote:
A more interesting question .. why do you need this? And, for your
need, have you explored other ways to solve the problem within the
existing Lua language?
I've used recursive pseudo-anonymous functions before. _SELF would make
them easier to use.

f((function()
   local function inside_anonymous(args, I, should, take)
   end
   return inside_anonymous
end)())
   You just need a Y-combinator:

	function Y(f)
	  local function g(...) return f(g,...) end
	  return g
	end

	print(Y(function(rec, x)
			if x < 2 then
				return 1
			else
				return x * rec(x-1)
			end
		end)(5))

   That will allow you to call an anonymous function recurively from within
the anonymous function.  No need for _SELF in this case.

   -spc (Now, about that _SUPER ...  )



That doesn't solve the dynamic variable indexing issue.

--
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.