Archived

This topic is now archived and is closed to further replies.

Kylotan

Lua: lua_dostring, loadstring, lua_load, etc

Recommended Posts

I think this was covered before, but it came up again today when I was talking about recompiling code from a string: Lua 4.0 has a function called lua_dostring() which executes a string, treating it as Lua code. Lua 5.0 mentions (near the bottom of the manual) that ''dostring is deprecated. Use loadstring instead''. But there is no loadstring (or lua_loadstring) in the C API. I''m assuming you use lua_load() and that the mention of loadstring in the manual was just a mix-up. lauxlib.h provides lua_dostring() in the Compatibility section so I assume you can still use that anyway, it seems. Does anybody know if my theory is right though? [ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The mention in the manual about loadstring refers to Lua code.

You should use lua_load instead of lua_dostring in C code.

Share this post


Link to post
Share on other sites
Yeah, that would make sense, except that it''s a bit nonsensical to say that a Lua function can make a C API function deprecated. Oh well.

[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I''m told there''s a luaL_dobuffer (or something, note the "L" utility function, but I haven''t checked this out yet.

Share this post


Link to post
Share on other sites