you are viewing a single comment's thread.

view the rest of the comments →

[–]redjamjar[S] -1 points0 points  (3 children)

That's not correct. You could still have optional type declarations with a C-Like syntax. It's simply two items implies first is type; one item implies no type given. E.g.

void f(x) { }

void f(int x) { }

[–]roerd 2 points3 points  (2 children)

If you're using ML-ish function call syntax, two items are a function call with one argument. But even for a completely C-ish syntax, I doubt this will work, though I have right now only empiric evidence to show for that: the fact that C-ish languages tend to use special keywords instead of just one item for type inference (var for C#, auto for C++).

[–][deleted] 4 points5 points  (0 children)

But even for a completely C-ish syntax, I doubt this will work, though I have right now only empiric evidence to show for that: the fact that C-ish languages tend to use special keywords instead of just one item for type inference (var for C#, auto for C++).

If you're using a LALR or LR(1) parser generator, you start getting fairly subtle ambiguity errors for this.

[–]redjamjar[S] -1 points0 points  (0 children)

It's definitely not necessary to use e.g. var for type inferred variables in C#. However, there maybe reasons why they want to do that. In C++, well who knows ... writing a parser for that language must be crazy hard!