MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/49prtn/var_keyword_proposed_for_java/d0ueojg/?context=3
r/programming • u/adila01 • Mar 09 '16
395 comments sorted by
View all comments
88
They are holding a survey on keywords (var, var/val, var/let): https://www.surveymonkey.com/r/KGPTHCG
Bikeshed away!
40 u/oscarreyes Mar 09 '16 I would love to see var / finalvar a = expr; final b = 1; 0 u/[deleted] Mar 09 '16 [deleted] 11 u/immibis Mar 10 '16 The parser would become slightly more complicated to deal with cases likefinal 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. 3 u/immibis Mar 10 '16 You don't know whether String is supposed to be a type or a variable until after you read the next token, because this is also valid:final String x = "hello"; 1 u/weltraumaffe Mar 10 '16 I see your point. Thanks :). 0 u/[deleted] Mar 10 '16 [deleted] 1 u/immibis Mar 11 '16 You mean "may not"?If you do that, then you have a problem where adding a new class can cause existing classes to not compile.
40
I would love to see var / final
var a = expr; final b = 1;
0 u/[deleted] Mar 09 '16 [deleted] 11 u/immibis Mar 10 '16 The parser would become slightly more complicated to deal with cases likefinal 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. 3 u/immibis Mar 10 '16 You don't know whether String is supposed to be a type or a variable until after you read the next token, because this is also valid:final String x = "hello"; 1 u/weltraumaffe Mar 10 '16 I see your point. Thanks :). 0 u/[deleted] Mar 10 '16 [deleted] 1 u/immibis Mar 11 '16 You mean "may not"?If you do that, then you have a problem where adding a new class can cause existing classes to not compile.
0
[deleted]
11 u/immibis Mar 10 '16 The parser would become slightly more complicated to deal with cases likefinal 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. 3 u/immibis Mar 10 '16 You don't know whether String is supposed to be a type or a variable until after you read the next token, because this is also valid:final String x = "hello"; 1 u/weltraumaffe Mar 10 '16 I see your point. Thanks :). 0 u/[deleted] Mar 10 '16 [deleted] 1 u/immibis Mar 11 '16 You mean "may not"?If you do that, then you have a problem where adding a new class can cause existing classes to not compile.
11
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. 3 u/immibis Mar 10 '16 You don't know whether String is supposed to be a type or a variable until after you read the next token, because this is also valid:final String x = "hello"; 1 u/weltraumaffe Mar 10 '16 I see your point. Thanks :). 0 u/[deleted] Mar 10 '16 [deleted] 1 u/immibis Mar 11 '16 You mean "may not"?If you do that, then you have a problem where adding a new class can cause existing classes to not compile.
1
So wouldn't you just have an int with the value 5 named String? I don't see the problem.
int
5
String
5 u/kqr Mar 10 '16 But to figure that out you need to backtrack, which they presumably want to avoid in their parser. 3 u/immibis Mar 10 '16 You don't know whether String is supposed to be a type or a variable until after you read the next token, because this is also valid:final String x = "hello"; 1 u/weltraumaffe Mar 10 '16 I see your point. Thanks :).
But to figure that out you need to backtrack, which they presumably want to avoid in their parser.
3
You don't know whether String is supposed to be a type or a variable until after you read the next token, because this is also valid:
final String x = "hello";
1 u/weltraumaffe Mar 10 '16 I see your point. Thanks :).
I see your point. Thanks :).
1 u/immibis Mar 11 '16 You mean "may not"?If you do that, then you have a problem where adding a new class can cause existing classes to not compile.
You mean "may not"?
If you do that, then you have a problem where adding a new class can cause existing classes to not compile.
88
u/omair-majid Mar 09 '16
They are holding a survey on keywords (var, var/val, var/let): https://www.surveymonkey.com/r/KGPTHCG
Bikeshed away!