lua-users home
lua-l archive

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




On 18/07/16 04:21 AM, Tim Hill wrote:

On Jul 17, 2016, at 8:32 PM, Philipp Janda <siffiejoe@gmx.net <mailto:siffiejoe@gmx.net>> wrote:


The point is really this: __key modifies the contract for a table
dramatically.

What exactly is the contract for a table? Taking metamethods into account there is not much we can say for sure about the behavior of a table ...


To my mind there is a huge difference between explicitly modifying table behavior via a metatable, and having behavior changed as a side effect of storing a userdata item as a key.

You don't seem to have any issues with integral floats. How are they any different?

As I and others have noted, the functionality needed by the OP can be done by interning, or by the appropriate use of metatables.


With returning plain integers (for interoperability with plain Lua keys) I'd have to use bigint.add(bigint(1), bigint(2)) instead of bigint(1) + bigint(2), which makes it literally impossible to write code that works with both bigints and plain numbers.

With __index and __newindex I can't use code I don't control.

And as others have noted, this thread is really going nowhere and is now drifting into ad hominem (not by you), so I’m dropping out.


This isn't ad hominem.
—Tim


--
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.