Draft JEP: Keyword Management for the Java Language (original) (raw)
Alex Buckley alex.buckley at oracle.com
Wed May 1 19:22:10 UTC 2019
- Previous message: Draft JEP: Keyword Management for the Java Language
- Next message: Draft JEP: Keyword Management for the Java Language
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Remi, thanks for your comments.
On 5/1/2019 5:07 AM, Remi Forax wrote:
- for the constraints on hyphenated keywords, using int-typed expressions is perhaps a little too clever because the compiler has to provide meaningful error message for the user (and IDEs automatic completion of not yet fully form expressions), by example, if there is an hyphenated keyword new-fun, for the snippet return A::new-fun, the expression is not valid but there are two interpretations A::new - fun or A:: new-fun. I think it's better to use a grammar approach (which keywords can be at left side or right side of an expression). Also the current rule doesn't work well if in the future we want to introduce operator overloading.
I had some trouble understanding "using int-typed expressions is perhaps a little too clever", because they're just examples to make a point, while "a little too clever" is the kind of comment usually targeted at a fundamental design decision. I think what you mean is "a little too limiting". To spell it all out:
Type-correct expressions that perform subtraction are part of the "overlap" with hyphenated keywords; and
Type-incorrect statements that complete abruptly are part of the overlap too (
throw-quickly
is syntactically valid today -- it will lex and parse ifquickly
is a numeric variable -- but it is also semantically invalid (type error), so we COULD reclassify it as a hyphenated keyword, but we have ALREADY decided not to, per howthrow
is mentioned in set A); and[Remi's observation] Type-incorrect expressions that perform subtraction are part of the overlap too (
A::new-fun
is syntactically valid today, but semantically invalid, so we COULD reclassify it as a hyphenated keyword, but we should be consistent with #2 and forbidnew-*
hyphenated keywords like we do forthrow-*
).
(You also raise the point that if the -
operator could be overloaded,
then it might be semantically valid for the left operand to be a method
reference expression involving ::new
, and that would clash super-badly
with new-*
hyphenated keywords.)
tl;dr I will add new
to set A, and avoid so much focus there on
int-typed expressions.
- the example total-switch in section "hyphenated keywords" is invalid given the constraints you give.
Oops! Removed.
Alex
- Previous message: Draft JEP: Keyword Management for the Java Language
- Next message: Draft JEP: Keyword Management for the Java Language
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]