Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!cornell!uw-beaver!teknowledge-vaxc!sri-unix!garth!smryan
From: smryan@garth.UUCP (Steven Ryan)
Newsgroups: comp.lang.misc
Subject: Re: Many people's opinions on computer languages (was: Third public review of X3J11 C)
Message-ID: <1440@garth.UUCP>
Date: 19 Sep 88 21:01:42 GMT
References: <8365@smoke.ARPA> <225800053@uxe.cso.uiuc.edu> <8374@smoke.ARPA> <340@quintus.UUCP> <910@l.cc.purdue.edu> <8695@ihlpb.ATT.COM> <1386@garth.UUCP> <585@aiva.ed.ac.uk> <1433@garth.UUCP> <429@quintus.UUCP>
Reply-To: smryan@garth.UUCP (Steven Ryan)
Organization: INTERGRAPH (APD) -- Palo Alto, CA
Lines: 30

>>If short-circuit && and || were not defined, then p && q and p || q
>>could be equivalent to p & q and p | q, with programmer responsible for
>>dangerous side-effects. In Ada this would perturb the code,
>>but it is not a problem in C or Algol because of the existence of conditional
>>expression.
>
>I am puzzled by the reference to ADA, which has
>	and {roughly "&"}		and then {same as "&&"}

Ada has and-then/or-else but doesn't have conditional expressions.
Pascal does/does not have either.
>	or  {roughly "|"}		or else  {same as "||"}
>and is thus the same as C (apart from having a separate boolean type).
>Why I say "roughly" is that if p and q are completely free of side effects,
>it is still not the case that "p&&q" and "p&q" have the same value.
>Consider, for example, p==4, q==2.  Then p&&q is defined to be 1, but
>p&q is 0.  For the same numbers, p||q is also 1, but p|q is 6.
>If you want an expression with the same value as p&&q, you have to write
>	!!(p) & !!(q)
>
>There are three separate things:
>   (a)	bitwise masking operations
>   (b)  "pure" logical operations
>   (c)  short-circuit operations
>Fortran and Pascal conflate (b) and (c), leaving it up to the compiler to
>decide which to use.  C omits (b), providing only (a) and (c).  Algol 60
>provides (b) and if-expressions.  Algol 68 provides (a), (b), and if-
>expressions.  I think most people will agree that C is an improvement over
>BCPL, where the same symbol was used for both & and &&, but if you used it
>in a "value" context you got "&", while in a "control" context you got "&&".