Switching on float/double/long

Dan Smith daniel.smith at oracle.com
Fri Dec 15 19:58:03 UTC 2017


> On Dec 13, 2017, at 5:51 PM, John Rose <john.r.rose at oracle.com> wrote:
> 
> But we only get to set the default once.  So perhaps we should delay
> supporting floats directly, until we can put all three or four float
> matching predicates in front of us and decide which is the default.

> On Dec 14, 2017, at 9:09 AM, Kevin Bourrillion <kevinb at google.com> wrote:
> 
> Switch on long: sure.
> 
> Switch on float/double: why?

When you guys say you'd like to _not_ support floating-points, I'm not sure what you mean.

The input to a switch can have any type, including Object. Some Objects may be Floats or Doubles.

A constant pattern may be any constant expression. Some constant expressions are floats or doubles.

I guess we could claim that floating-point constants can't be constant patterns, but that would be an awkward exclusion, since any other constant expressions work. We've got an ugly assortment of different flavors of "constant", and it would sure be nice not to add another.

Anyway, details aside, what you think you're asking for (I presume) is to hold off on implementing a new feature, but the reality seems to be that the request means actively prohibiting something that otherwise would Just Work.

—Dan


More information about the amber-spec-experts mailing list