lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index] <> wrote:

> I am imagining changing ltable.c:hashpointer to a function which when
> called with a pointer p, looks p up in an internal hash table IHT.  If p
> is already a key in IHT, the new hashpointer function would return the
> value there, and if not, it would
>   1) generate a hash value h from a deterministic series (just some
> PRNG with a fixed seed, which does not refer to p at all),
>   2) store the (p, h) pair in IHT, and
>   3) return h.
> Thus, as long there is a fixed order in which objects are assigned as
> keys to a Lua table T (which should happen if execution is
> deterministic), the hash values used to store them in T will be fully
> determined by the PRNG, and hence fully deterministic.
> Does this sound workable?  I welcome any comments or criticism.

Sounds quite plausible. Another option might be to eagerly store the PRNG
value in the object itself.

f.anthony.n.finch  <>
Trafalgar: Southwesterly veering northwesterly 5 or 6, occasionally 7 in
north. Rough or very rough. Rain or showers. Moderate or good.