I saw a really confusing statement when I read OMOHUNDRO's article about balltree construction algorithms:
--...
if pq.empty or else
btm.bvol <= pq.top.bvol then done:=true
--...
I don't know how could an 'else' follows 'or' and there is empty after the 'or'. could someone reorganize it and explain the branches of this statement?
The
andandoroperators in Eiffel are eager: they will evaluate both operands.Meanwhile,
and thenandor elseare the corresponding short-circuiting operators. They will cease evaluation as soon as the result of the boolean expression is known.In the example given, if
pq.emptyis true,btm.vol <= pq.top.bvolwill not be evaluated, since the result of the expression is already known to be true, regardless of the value of the second comparison.