[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Array Logical Operators
- From: Roberto Ierusalimschy <roberto@...>
- Date: Fri, 21 Oct 2011 14:26:15 -0200
> 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.
Exaclty. In Lua, as in many other languages, 'and' and 'or' are not
exactly operators; they are more like control structures. They do not
generate a single opcode, but a sequence of tests and jumps.
In statically typed languages, the compiler knows in advance what to
do. For a dynamic language, once the control code is generated, it is
hard to change it.
-- Roberto