lua-users home
lua-l archive

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

I notice a few messages circulating on this.

One feature I would like to see is the relaxation of the rules regarding the
invocation of the == metamethod on userdata tables. It currently regards
anything with a different metatable or a different type as not equal. In a
context where the datatypes have been extended and type corecion is employed
this leads to very hard to find 'bugs'. It would be a trivial matter for the
metamethod to make the distinction if it was important, so there is no loss
of generality if the rule is relaxed.

With the rule as is you can get into sillies, consider this:

MyNumber = f(2) --where f() is some userdata constructor making the
equivalent of the number 2
YourNumber = 2 --a native Lua number
assert(MyNumber == YourNumber,'now 2 does not equal 2!')

A person code reading this sort of problem typically takes a very long time
to realise what went wrong (i.e. me).

I'd vote for either relaxing the rule or throwing an error (the latter would
be more consistent with other errors, like doing arithmetic on strings).
Just silently saying FALSE is very hard to debug.


Dave Nichols
Match-IT Limited
Tel: 0845 1300 510
Fax: 0845 1300 610

Email Disclaimer: The contents of this electronic mail message and any
attachments (collectively "this message") are confidential, possibly
privileged and intended only for its addressee ("the addressee"). If
received in error, please delete immediately without disclosing its contents
to anyone. Neither the sender nor its management or employees will in any
way be responsible for any advice, opinion, conclusion or other information
contained in this message or arising from it's disclosure.