Re: (TC304.2308) translating logical operators

From: John Cowan (
Date: Fri Jun 09 2000 - 12:08:33 EDT

On Fri, 9 Jun 2000, Alain wrote:

> >Yet for old-fashioned programmers, this is generally clear. It was said
> >that some programming language (I forgot which) allows `and then' and
> >`or else' as an attempt to make things more clear.

The language is Ada.

However, there is a difference in behavior between "and" and "and then".
With "and then", the right-hand operand is not computed at run-time
if the left-hand operand is known to be false, since the result must
be false. With "and", this is not the case.

Similarly, "or else" does not examine its right-hand operand if the
left-hand operand is known to be true.

C/C++/Java/Perl programmers know this under the names of "&" vs "&&"
and "|" vs. "||" operators.

John Cowan                         
	"You need a change: try Canada"  "You need a change: try China"
		--fortune cookies opened by a couple that I know

This archive was generated by hypermail 2.1.2 : Tue Jul 10 2001 - 17:21:03 EDT