[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Lua Chunk Type
- From: "Leinen, Rick" <RLeinen@...>
- Date: Fri, 5 Aug 2016 21:28:27 +0000
>>2016-08-05 22:15 GMT+02:00 Leinen, Rick <RLeinen@leviton.com>:
>>> Or I guess it is more correct to say the function returned.
>>A function is a first-class value, so you can store it in any Lua table. For example, the registry.
>Thanks Dirk,
>Yes I have seen that done, but is there any way I can save it as a C type and use lua_pushvalue just before calling lua_pcall?. This seems to be cleaner from >the C side.
>Rick Leinen
Looking at this more closely, I don't think lua_pushvalue will work. I got this from this answer on stack overflow:
"Continue to use luaL_loadbuffer to load scripts. Load here means precompile. Just save the function left on the stack somewhere in your program (or leave it on the stack if you can). When the time comes to run a script, lua_pushvalue and lua_pcall it"
I believe the responder was suggesting leaving it on the stack. But he also suggested saving it in the C program which I like because I am going to have many scripts running.
Rick