lua-users home
lua-l archive

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


On 16.03.2018 09:12, William Ahern wrote:
On Fri, Mar 16, 2018 at 07:54:12AM +0100, Thomas Jericke wrote:
On 16.03.2018 00:37, Duane Leslie wrote:
Hi,

A quick and dirty tuple implementation using the new multi-uservalue
userdata implementation.
The problem I see, is that you don't get raw equality with any userdata
implementation of tuples. So I cannot use them as table keys.
For example I cannot use tuples to index a matrix.

t = {}
t[tuple(2,2)] = 42
print(tuple(2,2)) -- prints nil
You can memoize using an ephemeron table.

Not saying that this doesn't work, but what would I use as the key of the ephemeron table? I still need to somehow "hash" or concatenation the tuple into some raw type. And then why I am asking myself, why don't just use tables all the way. Maybe there is a performance benefit?
--
Thomas