lua-users home
lua-l archive

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


Hello!

Yeap, your little "CurriedLoops" thingy works...but you lost execution
performance...

If i'am not wrong, each call will generate "phantom" calls to CurriedLoops..

And i want if possible to fix this on the C/C++ side...

The most valuable solution will be to tell the vm to stay at current
instruction and not to go to next...

If anyone has a solution on the C/C++ side i take it...

But thanks guys.


JC.
 

-----Message d'origine-----
De : lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] De la part de Daniel
Silverstone
Envoyé : vendredi 22 octobre 2004 15:10
À : lua@bazar2.conectiva.com.br
Objet : RE: PATCH: true C coroutines -- yield across C stack from anywhere

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