Amusingly, the Delphi dialect of Pascal has an ambiguity in its grammar from how it made function pointers work:
function g: Integer;
// ...
f(g);
Depending on the definition of f, this could be passing the function f by reference (as a function pointer), or passing the result of calling f.Delphi looks at the argument type to resolve the ambiguity, but it stays awkward in overload scenarios, when there's a choice between Integer or function pointer arguments.
At some point around about 2009, I added the ability to specify explicitly that you want the call, to eliminate the ambiguity:
f(g());Rust has made a point of being parser-friendly, to support tooling. The entire reason the turbofish ::<> exists is to avoid ambiguous grammar. (This operator seems to vex people, I don't get the hate.)
One thing to avoid is depending on the existence of the symbol table to parse correctly. (C++ has this problem.) Needing a symbol table makes it hard for parsers like source code formatting and syntax highlighting.
Another is to avoid raw string literals that reach back and try to unwind the results of previous "phases of translation".
Redundancy in syntax can be a bonus.
I agree. I even wrote an article about that:
An easy solution to the problem would be to do what e.g. Haskell does where case-sensitivity determines a type name. For better or worse, C didn't do that.
[string] $foo = "foo"
*c;
at the beginning of a translation unit.Didn't K&R have a tiny, tiny C declarations parser (printing out 'human readable' equivalents) example in their book? I think the caveat was that it needs to assume it's dealing with a declaration...
It's a big win if files are parseable without their dependencies. The Pascal/Modula/Ada family all are. I think Go is. Not sure about Rust, but it probably is. C and C++, no.
(The hacks for template syntax in C++ are painful to think about.)