New candidate JEP: 441: Pattern Matching for switch
David Alayachew
davidalayachew at gmail.com
Sat Mar 18 22:14:41 UTC 2023
Hello Holo,
Thank you for your response!
> JEP 433, 427, 420, 406 all have a word
> about parenthesized patterns. Maybe an
> example like in your [2] would have been
> more clear, but the existence and
> grammar of parenthesized patterns
> existent from the first preview.
Looking back at them, you are definitely right. They all do mention it like
you said. But reading each JEP's section on it, I think I see where I was
coming from when I originally made my point.
I saw that you can put parentheses around the pattern, but they pretty much
just said "improves readability". The links I mentioned said that, then
showed you what the parentheses were protecting you from. Specifically,
parentheses allow you to use lambdas and switch patterns together without
messing up the order of operations. And like you said, the code example
makes it entirely unambiguous.
Could we add a code example for this JEP? If not that, then maybe just link
to the equivalent of what I linked, but for the respective version of Java?
Thank you for your help!
David Alayachew
On Sat, Mar 18, 2023, 6:33 AM Holo The Sage Wolf <holo3146 at gmail.com> wrote:
> JEP 433, 427, 420, 406 all have a word about parenthesized patterns.
> Maybe an example like in your [2] would have been more clear, but the
> existence and grammar of parenthesized patterns existent from the first
> preview
>
> On Sat, Mar 18, 2023 at 5:59 AM David Alayachew <davidalayachew at gmail.com>
> wrote:
>
>> Hello Amber Dev Team,
>>
>> I am very excited for this feature. I think the new levels of
>> exhaustiveness that this feature enables will remove a common source of
>> bugs for me when I write code.
>>
>> Looking at the link, I am very happy to see that switch expressions will
>> now play nicer with enums under a sealed type. This was a pain point for
>> code I was writing a few months ago [1], so having this will streamline my
>> development by a lot.
>>
>> I also very much like to see that parenthesized patterns are being
>> removed, to be handled later. In general, I like the idea of simply
>> deferring the uncommon edge cases to be dealt with in the future. Curious
>> to see how it will be dealt with in the future.
>>
>> That said, could we add a short description of what parenthesized
>> patterns are? Perhaps I missed a discussion on it, but I didn't even know
>> that they existed until I saw this JEP back when it was a JEP Draft. And if
>> not a description, maybe a link to some official Oracle documentation? This
>> link [2] is how I figured out what parenthesized patterns are.
>>
>> Thank you all for your time and effort!
>> David Alayachew
>>
>> [1] =
>> https://mail.openjdk.org/pipermail/amber-dev/2022-October/007528.html
>>
>> [2] =
>> https://docs.oracle.com/en/java/javase/19/language/pattern-matching.html#GUID-3EEBECEA-D874-4B20-B46B-07ED6172881D
>>
>>
>
> --
> Holo The Wise Wolf Of Yoitsu
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20230318/9561f684/attachment.htm>
More information about the amber-dev
mailing list