🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.c
Article #9458

Re: Expression sequencing query

#9458
From: Pedz Thing
Date: Tue, 30 Sep 1986 16:17
36 lines
1648 bytes
In article <673@galbp.UUCP> gbm@galbp.UUCP (Gary McKenney) writes:
>> In article <760@oakhill.UUCP> tomc@oakhill.UUCP (Tom Cunningham) writes:
>> >	/* a = b + b + b */
>> >	a = ((b=1),b) + ((b=2),b) + ((b=3),b)
>> >

Lets change the expression from
	a = ((b=1),b) + ((b=2),b) + ((b=3),b)
to
	a = ((a1),r1) + ((a2),r2) + ((a3),r3)

Where a1 stands for assignment (to b) 1 and r1 stands for reference
(to b) 1.  The following conditions must be meet for proper code:
a1 before r1
a2 before r2
a3 before r3

That is all of the restrictions imposed by C.  Thus the following is
correct code:

a3, a2, a1, r1, r2, r3

which produces the answer of 3.  I think I can come up with correct
code which produces an answer anywhere form 3 to 9.

This same question comes up every few days it seems like.  I do not
see what is so confusing about it.  The simple law that C imposes no
restrictions on the ordering of most operators never seems to be
understood.

Perry
-- 
Perry Smith
ctvax ---\
megamax --- bobkat!pedz
pollux---/
Technical Details
Message-ID: <137@bobkat.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!cuae2!ltuxa!we53!sw013b!dj3b1!killer!ndmce!pollux!bobkat!pedz
References: <760@oakhill.UUCP> <111@titan.UUCP> <673@galbp.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!cuae2!ltuxa!we53!sw013b!dj3b1!killer!ndmce!pollux!bobkat!pedz
From: pedz@bobkat.UUCP (Pedz Thing)
Newsgroups: net.lang.c
Subject: Re: Expression sequencing query
Message-ID: <137@bobkat.UUCP>
Date: Tue, 30-Sep-86 12:17:46 EDT
Article-I.D.: bobkat.137
Posted: Tue Sep 30 12:17:46 1986
Date-Received: Sat, 4-Oct-86 05:43:43 EDT
References: <760@oakhill.UUCP> <111@titan.UUCP> <673@galbp.UUCP>
Reply-To: pedz@bobkat.UUCP (Pedz Thing)
Distribution: net
Organization: Digital Lynx; Dallas, TX
Lines: 36