top | item 9138999

(no title)

josephschmoe | 11 years ago

Is there some reason we can't just do away with both and consider spaces in languages?

discuss

order

tzs|11 years ago

I've often wanted spaces in C. Because C makes heavy use of required punctuation, there aren't many places that a keyword can be adjacent to an identifier, or two identifiers can be adjacent, so for the most part I don't think spaces would introduce ambiguity.

Offhand, I can only think of a couple problem areas (but my C language lawyer days are long gone and I'm way out of practice--anyone else have some I'm missing?).

1. "goto foo;" could either be a goto keyword and the label foo, or a really stupid expression involving the variable "goto foo".

2. "int foo();" could be a forward declaration of the function foo, or an invocation of the function "int foo".

There would also be some questions about preprocessing. If I have something like "x pos = 12;", and I have a #define pos foo" in effect, does that apply to the "pos" in my "x pos"?