Re: _SELF and _SUPER
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: _SELF and _SUPER
- From: "Soni L." <fakedme@...>
- Date: Sat, 6 Aug 2016 17:45:24 -0300
On 06/08/16 05:36 PM, Sean Conner wrote:
It was thus said that the Great Soni L. once stated:
On 06/08/16 05:30 PM, Sean Conner wrote:
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.
That doesn't solve the dynamic variable indexing issue.
Oh, I'm sorry I failed to read your mind again. I thought that was what
_SUPER was for. I'm so sorry you have to reject MY ATTEMPT to give you
something you could use and grovel that I have to have your proposal
explained to me like I'm five.
-spc (Why do I even bother?)
No, I said _SUPER is exactly like _SELF but it uses the parent closure
instead of the current closure.
Which's why you can do things like
_SELF._SELF._SELF._SUPER._SELF._SUPER._SUPER._SUPER(some,args,here)
--
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.