4 ms·
> it's not yet clear to the parser Not at all. C/C++ grammar is explicitly contextual. `foo * bar` is a declaration if-and-only-if `foo` was previously decla
by colanderman 8y ago
> it's not yet clear to the parser
Not at all. C/C++ grammar is explicitly contextual. `foo * bar` is a declaration if-and-only-if `foo` was previously declared as a type. Otherwise it is an expression. The subsequent tokens have zero bearing on this.
Nor is this a good argument for types-to-the-right. If C named pointer types like `⋆foo` instead of `foo⋆` [stars used to avoid formatting glitches], then putting the type to the right as `bar * foo` would be equally ambiguous as your example.
- naniwaduni 8y agoplausible misread: "it's not at all clear"
- Guvante 8y agoI don't know of any language that has type on right without a non-ambiguous marker like `let`. That is what avoid ambiguity.
- colanderman 8y agoThe ambiguity issue the GP raised in type-on-the-left languages is also trivially solved by requiring `let`. That's not an argument for either style.
- Technetium_Hat 8y agoPython has (optional) types on the right, and no variable declaration keyword.