Feature Request for Primitive Patterns (JEP 455)

David Alayachew davidalayachew at gmail.com
Tue Sep 26 03:59:32 UTC 2023


Hello Brian,

Thank you for your response!

> We considered this for byte (and short and int and
> long...), but having written a lot of switches over byte,
> I am not sure I've encountered one that enumerates all
> 255 cases.

Fair point.

> If and when we have range patterns (n..m), I think the
> story might be different.

Woah, that would be perfect! Yeah, if range patterns are coming down the
pipe, I'm fine waiting for that before getting this.

Thank you for your time and help!
David Alayachew


On Mon, Sep 25, 2023 at 8:08 PM Brian Goetz <brian.goetz at oracle.com> wrote:

> We considered this for byte (and short and int and long...), but having
> written a lot of switches over byte, I am not sure I've encountered one
> that enumerates all 255 cases.
>
> If and when we have range patterns (n..m), I think the story might be
> different.
>
> On 9/25/2023 5:02 PM, David Alayachew wrote:
>
>
> Hello Amber Dev Team,
>
> I have a feature request to be included as part of JEP 455 -- Primitive
> Patterns.
>
> > Since the boolean type (and its corresponding boxed type)
> > has only two distinct values, a switch that lists both
> > the true and false cases is considered exhaustive:
> >
> > boolean b = ...
> > switch (b) {
> >   case true -> ...
> >   case false -> ...
> >   // Alternatively: case true, false -> ...
> > }
> >
> > It is a compile-time error for this switch to include a
> > default clause.
>
> I formally request that this functionality be extended to the primitive
> type byte.
>
> 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/20230925/13e0e869/attachment-0001.htm>


More information about the amber-dev mailing list