It seems to me that this comes up often enough that it satisfies the
definition of a FAQ. I know that
https://golang.org/doc/faq#convert_slice_of_interface is commonly
pointed to as an explanation, but it is not entirely satisfactory since
it is talking about the specific case of []T to []interface{} while
commonly people want to know about []T1 to []T2 where T1 and T2 are
derived from T, so another answer is probably warranted.

On Sun, 2016-08-28 at 22:43 -0700, Ian Lance Taylor wrote:
> 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.

Reply via email to