🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.c
Article #9396

Re: Expression sequencing query

#9396
From: Jason Zions
Date: Mon, 22 Sep 1986 23:15
34 lines
1978 bytes
> / tomc@oakhill.UUCP (Tom Cunningham) /  4:16 pm  Sep  5, 1986 /
> Sorry if this topic has been overly exercised already.  In the following
> code fragment:
> 
> 	/* a = b + b + b */
> 	a = ((b=1),b) + ((b=2),b) + ((b=3),b)
> 
[ Wants result to be 6; his micro compiler does that, his big system compiler
  produces 9. Doesn't know if it's a bug. ]
> Tom Cunningham     "Good, fast, cheap -- select two."
> UUCP:  {ihnp4,seismo,ctvax,gatech}!ut-sally!oakhill!tomc

Sorry. K&R does guarantee that the left side of a comma operator will be
evaluated sometime before the right side of the operator, but does not say
ANYTHING about interleaving evaluations of other expressions.

This was covered about a month ago, but not quite in the same context. The
upshot of it all was that interleaving of expression evaluation is indeed
legal, and some compilers (4.2BSD, I believe, is a notorious example) are
known to do so.

"Doctor, Doctor, I get bit every time I use multiple side-effects in the
 same statement!"

"So don't do that!"
--
This is not an official statement of Hewlett-Packard Corp., and does not 
necessarily reflect the views of HP. It is provided completely without warranty
of any kind. Lawyers take 3d10 damage and roll a saving throw vs. ego attack.

Jason Zions				Hewlett-Packard
Colorado Networks Division		3404 E. Harmony Road
Mail Stop 102				Ft. Collins, CO  80525
	{ihnp4,seismo,hplabs,gatech}!hpfcdc!hpcnoe!jason
Technical Details
Message-ID: <790003@hpcnoe.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!lll-crg!lll-lcc!qantel!hplabs!hpcea!hpfcdc!hpcnoe!jason
References: <760@oakhill.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!mnetor!seismo!lll-crg!lll-lcc!qantel!hplabs!hpcea!hpfcdc!hpcnoe!jason
From: jason@hpcnoe.UUCP (Jason Zions)
Newsgroups: net.lang.c
Subject: Re: Expression sequencing query
Message-ID: <790003@hpcnoe.UUCP>
Date: Mon, 22-Sep-86 19:15:50 EDT
Article-I.D.: hpcnoe.790003
Posted: Mon Sep 22 19:15:50 1986
Date-Received: Fri, 26-Sep-86 18:46:17 EDT
References: <760@oakhill.UUCP>
Organization: HP Colorado Networks Division
Lines: 34