[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Executing a script multiple times
- From: Matthew Paul Del Buono <delbu9c1@...>
- Date: Mon, 29 Sep 2008 13:11:22 -0400 (EDT)
>I found something in the documentation about pcall: "Then
>the program calls lua_pcall, which pops the chunk from the stack and
>runs it in protected mode", so I finally discovered what my error was
The best way to do this would probably be to not lose it after lua_pcall. Do you really want to recompile every time? If not, you could do something like this (semi-pseudocode):
/* Check for error conditions */
/* Make another reference to the function on the stack */
/* for x = 1 to n ... */
This should allow you to call lua_pcall as many times as you want without having to recompile it.
That being said, recompilation is only as expensive if it needs to be. Code first, profile and optimize after. I wouldn't recommend it, but recompiling is certainly a valid option if it's not too expensive for your needs.
-- Matthew P. Del Buono