powerful expressions

King Su wen-king at cit-vax.Caltech.Edu
Fri Dec 8 16:00:34 AEST 1989


In article <24735 at cup.portal.com> Tim_N_Roberts at cup.portal.com writes:
>In <12855 at cit-vax.Caltech.Edu>, wen-king at cit-vax.Caltech.Edu (King Su)
<shares:
>
<>	((qhead) ? (qtail = qtail->next = qnew)
>>		 : (qtail = qhead       = qnew))->next = 0;
<
>I am truly sorry for the order-of-evaluation flood that I am surely about
<to bring down upon myself, but...
>
<Is this guaranteed to work?

Yes.

Since the posting of the article, I have received exactly two replies.
One contains a better way to do the same thing:

    From: eggert at burns.twinsun.com (Paul Eggert)

		struct QUEUE *qhead = 0, **qtail = &qhead, *qnew;

	To append:

		*(qtail = &(*qtail=qnew)->next) = 0;

The other is a mild criticism.  To which my answer is that I now tend
use such expressions only in macros.  I used to put them in the program
body, but I have been doing less of that because it sometimes happens
that, as I was going through my old programs, I became totally
flabbergasted by some of the stuff I wrote.
-- 
/*------------------------------------------------------------------------*\
| Wen-King Su  wen-king at vlsi.caltech.edu  Caltech Corp of Cosmic Engineers |
\*------------------------------------------------------------------------*/



More information about the Comp.lang.c mailing list