Path: utzoo!attcan!utgpu!watmath!att!dptg!rutgers!cs.utexas.edu!uunet!mcvax!ukc!axion!tigger!raph From: raph@tigger.planet.bt.co.uk (Raphael Mankin) Newsgroups: comp.lang.c Subject: Re^2: comma operator, tetradic operators Message-ID: <538@tigger.planet.bt.co.uk> Date: 8 Aug 89 10:48:59 GMT References: <10099@mpx2.mpx.com> <93@microsoft.UUCP> <10100@mpx2.mpx.com> <918@helios.toronto.edu> <13074@megaron.arizona.edu> <9736@alice.UUCP> Organization: RT5111, BTRL, Martlesham Heath, England Lines: 32 debra@alice.UUCP (Paul De Bra) writes: >The following is also a problem: >if i have something like > if (e) > return; >and want to get some debug output, i would try > if (e) > printf("Hi\n"),return; >but this gives syntax error. (at least in the compilers i've tried) >Note that > if (e) > printf("Hi\n"),exit(); >compiles fine. It's just that "return" is treated differently. The difference is that 'return' is a statement and 'exit()' is an expression. Although exit() never actually returns a value the compiler does not know this. If we are going to change the C langauge definition then maybe we should go the way of Algol 68 and say that _everything_ returns a value, even if that value is 'void'. In this way several syntactic and semantic distinctions disappear and you can write: > if (e) > printf("Hi\n"),return; By the way, in Algol 68 loops return void, goto returns 'hip' which is a pecial sort of value that is coerceable to absolutely any type, since it will never be used. Raphael Mankin raph@planet.bt.co.uk