Deutsch   English   Français   Italiano  
<875xwj7kiw.fsf@fatphil.org>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Phil Carmody <pc+usenet@asdf.org>
Newsgroups: comp.lang.c
Subject: Re: while(T[l]<p & l<=r)
Date: Sun, 14 Apr 2024 23:32:23 +0300
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <875xwj7kiw.fsf@fatphil.org>
References: <uu109u$3798b$1@i2pn2.org> <uu3kqb$3i23g$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Sun, 14 Apr 2024 22:32:23 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="2ed98d0dc5d7de90f653feab8bc69573";
	logging-data="4017667"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19IdNar3Od0QvDOBOERjHu4"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:Np0H1Otm+0yy4rzO4c/8s/XHI5U=
	sha1:OncPL44DuWfdsJzWYwc0DWo378k=
Bytes: 1950

Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
> On 27.03.2024 12:35, fir wrote:
>> tell me, is while(T[l]<p & l<=r) the same as while((T[l]<p)&&(l<=r))
>
> 1. As long as K&R precedences still hold you don't need the inner
> parentheses; '<' and '<=' has higher precedence than '&' and '&&'.
> 2. In this case where you compare predicate expressions that
> evaluate to '0' and '1' on both sides of '&' and '&&' respectively
> these expressions are (while not the same) equivalent _here_.

The latter has shortcut semantics, and will only evaluate
r, and l a second time, if the first expression is true.
If r or l are memory mapped I/O, or similar, you might be
changing externally visible behaviour.

Phil
-- 
We are no longer hunters and nomads. No longer awed and frightened, as we have
gained some understanding of the world in which we live. As such, we can cast
aside childish remnants from the dawn of our civilization.
-- NotSanguine on SoylentNews, after Eugen Weber in /The Western Tradition/