lua-users home
lua-l archive

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


Quoth Gaspard Bucher <gaspard@teti.ch>, on 2010-12-31 15:21:43 +0100:
> What is the "official" way to determine if a table has a hash (in C) ?

No, no, no, nonononono.

No.

You don't.

A table is a table.  A table is not exactly an array or a hash.  The
fact that there are array-esque and hashtable-esque parts underneath
is irrelevant to the actual semantics of tables.  It is not part of
the interface.

If you want to make any semantic distinctions, you have to do it
yourself by defining some predicate on the set of keys in the table,
such as "tables with only contiguous positive integer keys starting
from 1 are treated as list-like".  Then you implement the predicate
yourself however you please (usually by iterating the keys and testing
for properties of the whole set).

   ---> Drake Wilson