Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!eos!ptolemy!raymond From: raymond@ptolemy.arc.nasa.gov (Eric A. Raymond) Newsgroups: comp.lang.c Subject: Re: When is a statement an expression? Message-ID: <1127@ptolemy.arc.nasa.gov> Date: 27 Apr 89 07:58:15 GMT References: <1043@itivax.iti.org> Reply-To: raymond@ptolemy.arc.nasa.gov (Eric A. Raymond) Organization: NASA Ames Research Center Lines: 26 In article <1043@itivax.iti.org> scs@vax3.iti.org (Steve Simmons) writes: > > a = if ( a == 1 ) > 12 ; > else > 14 ; Sorry, but C is not LISP. That is, compund (or complex) statements do not return values. You can accomplish this behavior via the ?: connstruct: a = (a ? 12 : 14); Incidently, I beleive the comma operator allows you to approach a progn (or is it prog1?): a = (x=1, y=2, z=3); A is 3 if the last expr is returned (progn-like), otherwise 1 (prog1-like). Look it up. -- Eric A. Raymond (raymond@ptolemy.arc.nasa.gov) G7 C7 G7 G#7 G7 G+13 C7 GM7 Am7 Bm7 Bd7 Am7 C7 Do13 G7 C7 G7 D+13: Elmore James