Knocking off two more vestiges of legacy switch

Brian Goetz brian.goetz at oracle.com
Tue Sep 13 17:31:38 UTC 2022



>> Which raises some questions (again) of the semantics of constant 
>> patterns for exotic floating point values, especially (again) 
>> negative zero.
>
>
> In a switching context, I think there is a stronger case for 
> distinguishing between +0.0 and -0.0. The operational semantics I'd 
> recommend are to desugar, say a float switch, to an int switch on the 
> Float.floatToIntBits mapping of the float case labels. 
> Float.floatToIntBits, as opposed to Float.floatToRawIntBits, 
> normalized all NaN representations to a single value.
>

This sounds right to me, but its not just about switch -- this would 
have to be the case for all constant patterns, such as

     if (x instanceof FloatHolder(Float.NaN)) { ... }

But I think your argument still applies here as well.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-spec-observers/attachments/20220913/5ff0f319/attachment-0001.htm>


More information about the amber-spec-observers mailing list