2 ms·
There are four possible spacings to consider: foo*bar; // multiplies foo and bar foo* bar; // declares bar as pointer-to-foo foo *bar; // declares *bar a
by a1369209993 7y ago
There are four possible spacings to consider:
foo*bar; // multiplies foo and bar
foo* bar; // declares bar as pointer-to-foo
foo *bar; // declares *bar as foo (so bar is still a foo*)
foo * bar; // multiplies foo and bar
These are all unambigous and there are only two semantics between them. You also have:
foo* bar,baz; // baz is a pointer
foo *bar,baz; // baz is a foo
foo *bar,*baz; // baz is pointer again
foo* bar,*baz; // baz is now a pointer *to* a pointer
This is all obvious - or at worst unambigous - to a person reading the actual code (without trying to correct for the idiosyncracies of a parser), so the language should either match that or spit out a warning about unsupported spacing.
> [`int c = x*y;` is] wrong.
No, that's unambigously multiplication.