"C" wish list/semicolons

FryPC pcf at drux3.UUCP
Fri Nov 8 02:59:45 AEST 1985


> Let (semicolons) them separate two staments on the same line. Let line breaks
> terminate statements if it makes sense to do so.
> ...
> Since modern languages like CLU, Icon and BCPL (BCPL! Waitaminute!) allow
> this, I think it belongs on any C wish list.
> ...
> P.S. No, I don't know why this disappeared between BCPL and C (at which
> step?). Anyone care to explain?

The problem is that C overloads operators, in particular "*"; as "*" can 
leagally start (indirection) or legally continue (multiplication) a statement.
Combined with the fact that assignments have a value, the following
fragment could be parsed in (at least) two ways.

	x = a * b		/*    x = a * b * (c = 1);  */
	*c = 1			/* or x = a * b; *c = 1;  */

A solution is to make "*" (indirection) a postfix operator. This would also
make declarators using pointers easier, as all modifiers would be postfix
and parentheses would not be required for grouping. You could read off
everything left to right.

Example:
A function returning  a pointer to  a function returning  an integer:

int (*func(args))()      becomes      int func(args)*()

And that is one thing on my 'I wish they had done it this way' list.

Peter Fry
drux3!pcf

"Oh Bullshot, you are wonderful."
"No, not wonderful, just British."



More information about the Comp.lang.c mailing list