On Wed, Jul 8, 2020 at 3:26 PM 'simon place' via golang-nuts
<golang-nuts@googlegroups.com> wrote:
>
> i was just reading that!
>
> does it mean (or just imply) that constant conversions are not implementation 
> dependent?

Constant conversions are mostly not implementation dependent.
Constant conversions follow the rules of general constant expressions
described at https://golang.org/ref/spec#Constant_expressions.  See
the "Implementation restriction" note at the end of that section.


> i remember wondering, a while ago, why it was that NaN etc. weren't 
> constants, after-all their encoding is unique and can't vary.
>
> seems the reason for this is.....
>
> "Numeric constants represent exact values of arbitrary precision and do not 
> overflow. Consequently, there are no constants denoting the IEEE-754 negative 
> zero, infinity, and not-a-number values."
>
> not sure how negative zero, for example, fails here, its a value of a float 
> type, so it is Numeric, an exact value, and i don't really see how "of 
> arbitrary precision and do not overflow" apply?

Constants in Go are intended to act more like mathematical
representations than like computer types.  Hence values have no
precision limits, and concepts like negative zero and infinity and NaN
do not exist.


> but this is stymieing the whole point of the way i was doing it, 
> simple/clear/short/std.lib leveraging,  because it seems you HAVE to check 
> them all, (NaN/+Inf/-Inf/-0) because an "implementation-dependent" value 
> could be anything and so potentially exactly what you were expecting right up 
> until it isn't!
>
> seems quite like map iteration randomisation. if it can be anything better 
> make it random to cause earliest failure.

Unfortunately I think using that approach for conversions would have
significant execution time costs.  For map iteration it's almost free.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcXwXFAddnjO9WkN-J3n2T%2B%2Bp_0sHqNiuhGu8SspyBBCMg%40mail.gmail.com.

Reply via email to