lua-users home
lua-l archive

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



On 11-Jun-07, at 3:45 PM, Steve Heller wrote:

By the way, do you know why == and ~= behave
differently from <=, etc. in this regard? It seems
inconsistent, and makes for more work when you have
type issues to deal with.

It would be really awkward if ==/~= threw errors.

  if a == b then ...

would have to be rewritten safely as

  if type(a) == type(b) and a == b then ...

Consider common cases such as b is nil, or b is a sentinel, etc.

In any event, it's clear that two objects of different types are
unequal, but have no ordering relationship. So comparison and
ordering operators are really different.