lua-users home
lua-l archive

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


> I think, the problem is that you don't know which tag method is called,
> that of the left or that of the right operand.  If both are of the same
> type there's no problem but if they differ you get a not-so-nice
> behaviour and the annoying effect that the tag method itself has to
> check whether its first or second arg is the "correct" type.

This is also true, and is potentially a problem with some of my libraries, 
it just occurs to me (though I don't think I've yet been bitten).

Of course, with static typing you can optimise and still have simple 
rules, as in Java, where the *effective* order of execution is defined, 
but the compiler can use associativity and commutativity where it can 
prove it's valid, e.g. on integers.

Which brings me to another problem: most Lua builds use floating-point
numbers. Floating-point arithmetic operations are often not commutative or
associative.

I'd be interested to see a real-world example of code where these
optimisations are a life-saver; otherwise I really don't see their point.

-- 
http://www.mupsych.org/~rrt/
penitent, a.  undergoing or awaiting punishment (Bierce)