lua-users home
lua-l archive

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

--- Rici Lake <> wrote:

> 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.

I suppose so. But then perhaps there should be
different operators that behave like "<=", etc. with
respect to types, but for (in-)equality of values.
Maybe === and ~==? That would simplify problems like
the one I have.

Or am I (almost) the only one with this problem? If
so, then of course it doesn't make sense to change the
language to meet my peculiar needs.