lua-users home
lua-l archive

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


teppy wrote:
Sorry to sound discouraging, but aren't you trying to go the hard way?
What considerations lead you to decision to change Lua itself? I
believe you'll lose much more than you gain (starting from LuaJIT
compatibility).

Why not, say, wrap access to "shared" tables into some API calls (if
needed, it may be made transparent by implementing a clever metatable
over a global environment)? Such API may call yield as needed then (if
you put into a metatable, you'll need to employ one of
cross-metamethod yielding libraries).

Alexander.

It's probably doable, but I think it leads to awkward code:

    1. The script programmers would then have to keep track of which
tables are foreign vs. local.
    2. Code becomes bulky (and maybe slow):

       player.inventory["mushrooms"]=player.inventory["mushrooms"]+1;

          instead of

MakeRes(MakeRes(player).inventory)["mushrooms"]=MakeRes(MakeRes(player).inventory)["mushrooms"]+1

    3. I investigated the metamethod idea - there's no way to define a
metamethod for changing an existing key, as in the above example. (Right?)
    4. Tables can point to other tables to form complex data structures.
Without a global ID for each table, knowing which tables to send to
connected players becomes a nightmare. Requiring programmers to always
initialize this for each table is error prone, and interferes with
garbage collection because now an "empty" table isn't really empty.

Teppy

Using metatables you could very well use:

player.inventory["mushrooms"]=player.inventory["mushrooms"]+1;

Transparently, you wouldn't even need to explicitly know it's a non-local table.

Olivier Hamel