[comp.lang.c] Re^2: comma operator, tetradic operators

raph@tigger.planet.bt.co.uk (Raphael Mankin) (08/08/89)

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