lua-users home
lua-l archive

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


hi all! :)


im wondering if a manual table rehash could be a useful utility for
experts in some rare cases (long living messy tables with much
contents and much deletes), or not? simply like
`table.rehash(aTable)`, i think it would be even a kinda cheap goodie,
but with much harmless uses that arent useful. :D maybe even for 5.4
:)

any ideas about this?

[not so important part]
my possible use case:
actually i have a function(((-like beast))) that is used for
traversing whatever structures (currently lua tables and half done for
fs) that can serve for
iter/dump/serialize/diff/search/analyze/whatever, even a stream based
(so iterative) parser can be used for making whatever text to be a
structure on the go (and more goodies are done/planned).

so the state (a table) of this have an array of tables that hold
whatever info about the nodes+leafs (path, val, whatever) and as this
can grow huge, but it isnt necessary to hold everything (like
traversed branches; or leafs, if i need to detect only recursions or
repetitions, but thats mostly a bad example, as i can skip them),
therefor i could actually delete some of the members of this array,
while it can be useful to keep it for whatever purpose, so the rehash
could be a thing here.
[/not so important part]



furthermore, i have some questions about the array<->hash part transitions:
- how it goes if i have int keys in the hash part, and fill up the gap
between the indices of the array part, and those that are in the hash
part?
- what happens when i delete a value from the middle of the array part?
- what about the expense of any related work?
- "dont try this at home" kinda hacks are also welcome! :D (anything
like unreliable implementation details as this
`assert(#{1,2,nil,4,nil,nil,nil,8}==8)`; and some more detailed info
on triggering the rehash with inserting `nil`s into a table, than what
lua programming gems have.)

if other lua implementations do a different thing, then im also
interested in those, especially luajit, but its good to know this
about any mostly compatible fork.



btw i just came across with https://www.lua.org/gems/ (therefore the
topic) and the links could get some review, like code.google.com is
already just history... (in the worst case, wayback machine could
help, but i think those lost bits exists somewhere else.)


many thx for ur time; and any info, help and whatever else; all the
bests to all of u! :)