Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!mit-eddie!genrad!decvax!ima!cfisun!lakart!dg From: dg@lakart.UUCP (David Goodenough) Newsgroups: comp.lang.c Subject: Re: When is a statement an expression? Message-ID: <522@lakart.UUCP> Date: 28 Apr 89 16:18:11 GMT References: <1043@itivax.iti.org> Organization: Lakart Corporation, Newton, MA Lines: 42 scs@vax3.iti.org (Steve Simmons) sez: > ...... > we wrote code like: > > main() > { > int a = 0 ; > > a = if ( a == 1 ) > 12 ; > else > 14 ; > printf( "Value of a is %d\n", a ) ; > } UUMMPHFF!!!! When did C compilers learn to talk ALGOL. Either that or it's a funky way of doing: a = (a == 1) ? 12 : 14; from a somewhat odd compiler. > We tried it out on all the C compilers we could find (BSD 4.3, Gould, > UNIX-PC, gcc) and it fails. I'm not in the least surprised - C was never specified to do that. > But the error messages are quite cryptic > (we like gcc: "parse error after 'a'") and largely don't address > the real problem. Basically the syntax is totally out to lunch, and different parsers will decide that different errors exist. > Anybody else ever use stuff like this? Not a chance - it's not legal C. -- dg@lakart.UUCP - David Goodenough +---+ IHS | +-+-+ ....... !harvard!xait!lakart!dg +-+-+ | AKA: dg%lakart.uucp@xait.xerox.com +---+