Finding the right keyword for new features (was "Re: Could we change the syntax for when clauses?")

Brian Goetz brian.goetz at oracle.com
Wed Dec 7 19:04:31 UTC 2022


Imagine we did this, and we added a dozen or so new #keywords to the 
language over the next ten years.  Now imagine you're a new developer 
learning Java. In addition to all the struggling with learning to 
program and learning the language, you're now also guaranteed to be 
distracted with "how do I remember whether it's "if" or "#if, and why 
can't the stupid compiler just figure it out for me?". And the 
explanation "Oh, that was added after the Great Sharpification" will not 
be compelling.

As a concrete example, this was tried in Java 5 with "@interface".  To 
this day, people complain about this, and with good reason: it is a 
gratuitous departure from the rest of the language.

We should strive to make the features we add look like they were there 
all along.



On 12/7/2022 1:55 PM, David Alayachew wrote:
> I have one more question I'd like to ask. Aside from this, I think 
> we've explored the idea well enough, so I'll leave the topic alone for 
> good.
>
> Are we opposed to doing something like this?
>
> case Integer i #when i > 0
>
> My goal here is to use the # symbol (or any other unused symbol) as 
> sort of a springboard into a larger pool of potential signifiers. You 
> get simplicity and expressiveness for the cost of one more character 
> that is currently unused (to my knowledge). Furthermore, the 
> introduction of the unused character can help with visually separating 
> the pattern from the guard, but with minimal loudness. And of course, 
> being unused means that it meets the needs for Java language parsing 
> folks too.
>
> Thank you for your time and help!
> David Alayachew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20221207/f40da622/attachment.htm>


More information about the amber-dev mailing list