On Fri, 1 Nov 2002, Damian Conway wrote:
: Austin Hastings wrote:
: 
: > In the C that I learned, the &^| ops were bitwise.
: > 
: > Likewise, the && || ops were lazy booleans.
: > 
: > So what's a single-letter boolean act like? Is it lazy? Does it retain
: > its bitwise-ness but (since boolean) force evaluation for 1 or 0 first?
: > I just don't understand what the "implied" behavior is, since the
: > reference is outside my experience.
: 
: Since they're producing a boolean result, both C<?&> and C<?|> could be
: implemented lazily. However, I suspect they mightn't be, just to keep
: them consistent (in their evaluation of operands) with the other bitwise
: ops.

What you're saying is correct, except that I don't think we should
be confusing "lazy" with "short-circuit".  A lazy operator wouldn't
evaluate *either* side until it jolly well had to.  If you say

    () = 1..Inf;

it shouldn't even try to produce a 1.

I don't much care whether they short-circuit or not.  I could argue it
either way.  I think it'd be okay if they short-circuit.  Anybody who
uses an operator like ?& expecting it to force a side effect on the
second expression is nuts.  And there's something (though not much)
to be said for having an exact equivalent for C's && operator.

Larry

Reply via email to