lua-users home
lua-l archive

RE: callback implementation details..

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


-- @func table.merge: Merge two tables
-- If there are duplicate fields, u's will be used. The metatable of
-- the returned table is that of t
-- @param t, u: tables
-- returns
-- @param r: the merged table
function table.merge (t, u)
 local r = table.clone (t)
 for i, v in pairs (u) do
 r[i] = v
 end
 return r
end
For the purpose of merging argument lists it appears that this table.merge
doesn't work quite as intended.
The tables (in essence both are arg) being merged for the purpose of
currying only use numerical indices (with exception of ['n'], of course). A
version of merge that uses ipairs (instead of pairs) and that appends at the
end of the table (instead of overwriting preexistent indices - which appears
to happen always in this case) should probably work better.
Marius Gheorghe

AltStyle によって変換されたページ (->オリジナル) /