lua-users home
lua-l archive

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


> I realise I've probably missed the boat by a long time for 5.2, but
> could I politely ask that you consider changing relational operators
> so that you can compare between objects with different metatables, and
> so that the operators can return results other than true or false?
> 
> Is this of interest to anyone else?  (I'd like to use it to write lp
> constraints: x + y <= 3, rather than rima.constraint:new(x + y, "<=",
> 3) )

We are considering the first change (compare objects with different
metatables). The second one is more complex, because it is more
ingrained. Even the opcodes for these operations assume boolean results:

  OP_LT,/*        A B C   if ((RK(B) <  RK(C)) ~= A) then pc++            */
  OP_LE,/*        A B C   if ((RK(B) <= RK(C)) ~= A) then pc++            */

This is not reason enough not to change, but it is something to be
weighted.

-- Roberto