lua-users home
lua-l archive

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


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.

> Also they are passed by reference and not by value. That can be confusing
> once you edit a value in that tuple.