lua-users home
lua-l archive

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


2014-08-24 2:57 GMT+02:00 Thiago L. <fakedme@gmail.com>:

> Let me explain that a bit better: you can set an __eq metamethod
> that lets you compare your special object to anything in any way
> you want (which may be useful for (for example) a big number library),
> but when you want a raweq, you have to use rawequal() (or is it
> rawequals? can't remember), which's a C function call, and we all
> know function calls can be expensive. Instead I want an
> OP_RAWEQ bytecode, and "a === b" to use it.

"Lua will try a metamethod only when the values being compared
are either both tables or both full userdata and they are not primitively
equal."

Remember, we only have six bits available, i.e. max 64 different
opcodes. Lua 5.3 uses 47 of those. Is saving a function call, no
extra functionality, in the event where we are dealing with heavy
structures anyway, worth spending one of the 17 remaining unused
opcodes?