r/programming • • Mar 09 '16

var keyword proposed for Java

http://openjdk.java.net/jeps/286
250 Upvotes

395 comments sorted by

View all comments

Show parent comments

0

u/[deleted] Mar 09 '16

[deleted]

11

u/immibis Mar 10 '16

The parser would become slightly more complicated to deal with cases like

final String = 5;
             ^ apparent parse error?

(In Java it is legal to have a variable with the same name as a type)

1

u/weltraumaffe Mar 10 '16

So wouldn't you just have an int with the value 5 named String? I don't see the problem.

5

u/kqr Mar 10 '16

But to figure that out you need to backtrack, which they presumably want to avoid in their parser.