lua-users home
lua-l archive

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


For me, this thread is just making tables too complicated. For tables I create in code, problems with nil easy to program around. For table operations on arbitrary data:

local fakenil=(}

function  nilin(val)

    if val==nil then val=fakenil end

    return val

end

function nilout(val)
    if val==fakenil then val=nil end
    return val
end

Use these functions in conjunction with table.insert ...., and # works fine on tables with with no holes. If you really need sparse arrays, it would be more complicated--but I have no need. Perhaps someone could make a sparse array library using userdata? I would use that if I needed it. Who has any problem using lfs if they need file operations more complex than the io library provides? But lfs is not part of the Lua core, nor is it a standard library. The same could happen with a well written sparse array library. They only thing I might like to see changed in the table library is to make table.pack and table.unpack symmetric, as has been discussed upthread.

-- Mike