On Wed, Apr 16, 2008 at 11:19:33PM -0400, Bob Rogers wrote: > Pardon a lurker, but I'm not sure I understand the point of this. In: > > if $x < $y < $z { ... } > > I would expect a sensible compiler short-circuit the "$x < $y" part, and > indeed the "Chained comparisons" section of S03 (version 135) says > > A chain of comparisons short-circuits if the first comparison > fails . . . > > But the definition of chaining associativity under "Operator precedence" > says this is equivalent to: > > if ($x < $y) and ($y < $z) { ... } > > (modulo multiple evaluation), but IIUC "and" is not short-circuiting.
"and" is short-circuiting. > And wouldn't it also be helpful to implement chaining in such a way > that a specialized chained op implementation couldn't mess it up by > returning plain True? FWIW, PCT and Rakudo do it this way -- the chained op returns a true/false value and doesn't have to be aware of any chaining taking place. Pm