lua-users home
lua-l archive

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

On 2017-01-27 10:22, Thijs Schreijer wrote:
> You’re always getting the `__name` field, shouldn't this only be done
> if the original type is one that allows for individual meta-tables?
> eg. not calling it on a `string`, but only on `table` and `userdata`
> types?

Well, it's just a very quick experiment to get a rough estimate of the
impact on speed.  (And I already don't like the effect... more checks,
calling extra functions, ... would only make it slower.)  I didn't
bother to think about whether this is actually useful in all cases.

Aside from that, it's natural for me to use metatables on primitive
types.  Makes for shorter code - no need to special-case or wrap
primitives (unless you need comparison operators).  So just always
returning __name if available seemed logical in some way.

-- nobody