lua-users home
lua-l archive

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


Hi,

RLake:
> Note undocumented feature in Lua 5.0 beta: if present, the metamethod
> __tostring will be called by tostring (and therefore by print). This must
> return a string or a number if you want print to work properly.

Thanks for the tip, I didn't know that one yet!  Scanning the sources for
"__" gives the following list of (partially) undocumented (meta)fields:

undocumented:

__eq  ~  [callable, in: left operand, right operand] test "==" equality
__metatable  ~  [any value] protects / masquerades the metatable
__tostring  ~  [callable, in: object] called by tostring
__globals  ~  [any value] protects / masquerades a table of globals.  Note:
the __globals field must be present in the table of globals itself, because
it is located with a rawget.

partially undocumented:

__eq, __lt, __le  ~  these will be used _only_ for operands of the same
type.

typos in documentation of __le:

1) returns op1 <= op2 for numbers and strings (instead of op1 < op2.)  ;-)
2) if absent, then getbinhandler(op2, op1, "__lt") is used (instead of
getbinhandler(op1, op2, "__lt")), actually the better choice.

Bye,
Wim