lua-users home
lua-l archive

RE: PATCH: true C coroutines -- yield across C stack from anywhere

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


On Fri, 2004年10月22日 at 15:00 +0200, Jean-Christophe Capdevila wrote:
> I want:
> 	While true do
> 		Goto(WayPointA)
> 		Goto(WayPointB) 	
> 		Goto(WayPointC)
> 		Goto(WayPointD)	
> 		PlayAndWaitAnim("dummyanim")
> 	end
> with your solution it will be :
> 	While true do
> 		while Goto(WayPointA) do
> 		end
> 		while Goto(WayPointB) do
> 		end
> 		while Goto(WayPointC) do
> 		end
> 		while Goto(WayPointD) do
> 		end
> 		while PlayAndWaitAnim("dummyanim") do
> 		end
> 	end
function CurriedLoops(func)
 local unpack = unpack
 return function(...) return while func(unpack(arg)) do end end
end
Goto = CurriedLoops(Goto)
PlayAndWaitAnim = CurriedLoops(PlayAndWaitAnim)
And lo the second mechanism works but looks like the first form :-)
D.
-- 
Daniel Silverstone http://www.digital-scurf.org/
PGP mail accepted and encouraged. Key Id: 2BC8 4016 2068 7895

AltStyle によって変換されたページ (->オリジナル) /