lua-users home
lua-l archive

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

On 07/10/15 11:33 AM, Dirk Laurie wrote:
2015-10-07 14:43 GMT+02:00 Soni L. <>:

On 07/10/15 04:50 AM, Dirk Laurie wrote:
2015-10-07 0:53 GMT+02:00 Soni L. <>:

loadx is a Lua 5.2 and Lua 5.3 library which provides a better `load()`.
currently supports:
- You can set ALL the upvalues, not just the first! This, combined with
above, makes this library perfect for seriali(s|z)ing and
(de|un)seriali(s|z)ing functions!
Maybe loadx could also return a table of upvalues, with names as
a list and values as a key-value pair, i.e.

f, upvals = loadx(chunk,nil,nil,'foo','bar')
-- upvals = {'a','b',a='foo',b='bar'}

A table of upvalue objects (the ones you get from newupval())?
I did not think of that, no: it's just that lua_setupvalue returns the
function's name for that upvalue, so it is easy to create a table
of actually supplied upvalues keyed by their names. Since the
order may be important, the names are keyed by 1,2,...

This is the table format also used by some XML-to-Lua modules.

But you gave as an example:


Ok, sure, 'a' and 'b' at [1] and [2] are the names. But ['a'] and ['b'] map to the values! Instead of mapping to the values passed, why not map to "upvalue objects"?

Also, what if you don't have any names?

Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.