As an aside - there is a complication to this if this (original post) were
allowed/added to the language specification
var (
a float32 = 1.0
aa []float32 = []float32{1.0, 2.0, 3.0}
)
b := float64(a) //is ok
bb := ([]float64)(aa) //not ok
If the second conversion bb was allowed it would require a lot of extra
magic work underneath -as a new slice would have to be created, large
enough to store float64s - not just a case of changing the slice header to
point at a new type.
So in reference to the original example - either extra code would have to
be added to do this work, or these cases of type conversion would have to
be dissallowed for slices.. Either way that's more compiler code, not less.
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.