lua-users home
lua-l archive

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


>From lua-l@tecgraf.puc-rio.br Tue Jul 27 07:58:15 1999
>From: David Jeske <jeske@chat.net>

>I'll restate the question as: If we define lua_dostring as:
>
>function lua_dostring(a_string)
>  a_block = lua_parsestring(a_string)
>  lua_doblock(a_block)
>end
>
>How do we do "lua_parsestring" and "lua_doblock"?

There's no official API for this, but you can look inside ldo.c and luac.c
and see how it's done: "lua_parsestring" would be luaY_parser;
"lua_doblock" would be luaD_protectedrun.

>I'd prefer to prevent any side-effects as
>a result of just bringing in a module.

Well, the whole point of loading a chunk is to have some side-effects!
(At least, some function definitions, which are simply assignments.)
Now, as you say, "chunks" are probably different from what you call "modules".
But I think Lua has the mechanisms to allow you to define your own semantics
for "modules", e.g., the setglobal tag method.
--lhf