On Sun, Aug 28, 2016 at 3:36 AM, <xiiop...@gmail.com> wrote: > > In fact T L's experience reminds me very much of probably my first > experience with go .. I had read the specification completely, and I thought > 'thoroughly' - then immediately tried this : > https://play.golang.org/p/or1Ikhr4en > > package main > > import ( > "fmt" > ) > > func main() { > var ( > x, y, z *string = new(string), new(string), new(string) > b []*string > ) > > str := "please parse this" > > b = make([](*string), 3) > > fmt.Sscan(str, x, y, z) > fmt.Sscan(str, b...) //doesn't work > fmt.Println("x", *x, "y", *y, "z", *z) > > fmt.Println("b", b) > } > > > the compile error is of course "cannot use b (type []*string) as type > []interface {} in argument to fmt.Sscan" - > > variadics are clear example of why allowing the suggested type conversion on > slices of convertible types would actually be useful..
I want to make clear that I do not think this is what TL was discussing. I think TL was asking about conversions of slices where the element types have the same underlying type, not where the elements types are convertible. I completely agree that allowing type conversions between slices of convertible types would be useful. This is not currently permitted because it requires an implicit loop at run-time. It means that a conversion from []T1 to []T2, although it looks like a simple change of representation, actually requires a loop over all the elements in the slice. 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. For more options, visit https://groups.google.com/d/optout.