[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua 5.4 Tuples FTW!
- From: Duane Leslie <parakleta@...>
- Date: Sat, 17 Mar 2018 08:24:34 +1100
> On 16 Mar 2018, at 23:54, Thomas Jericke <tjericke@indel.ch> wrote:
>
> Well I see how this can work, but then, this is nothing that could not be done with Lua 5.3 and tables.
Except that it was not easy to store `nil` previously. But yes, tables are sufficiently powerful to do pretty much anything with some effort.
The effort required is not so bad if you 'cheat' and use the internal structure of the userdata, because I believe the uservalue array can just be treated as a byte string that uniquely identifies the tuple. I'd have to play with this some more.
> I am actually struggling a little how I would implement a copy-on-edit. The __newindex metamethod gets the userdata and the field name and the new value as parameters.
I specifically would not implement `__newindex`, but rather use slicing and joining type operations since these semantically imply the return of a new object. Not very efficient, but then tuples shouldn't be edited in general.
Regards,
Duane.