lua-users home
lua-l archive

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


One problem is that the logical operators 'and' and 'or' use short-circuit evaluation, which is not easy to implement efficiently for user defined objects.

-- Gé

On Oct 21, 2011, at 4:55, Antonio Scuri <scuri@tecgraf.puc-rio.br> wrote:

  Hi,

 

  I created a class for arrays that use the arithmetic and relational operators. But I would like also to implement logical operators so I can write:

 

d = a<b and b<c

 

  I defined the result of the relational operators as another array of booleans with the result for each element. So naturally the logical operators would have to return also an array of booleans.

 

  I donâ??t need to define the meaning of â??if (a<b)â??, it can be an error.

 

  So, wouldnâ??t be interesting to Lua to have metamethods for Logical operators too?

 

Best Regards,

Antonio Scuri

Â