On Wednesday, August 3, 2016 at 6:16:37 PM UTC+2, Ian Lance Taylor wrote:
>
> On Wed, Aug 3, 2016 at 9:12 AM, T L <tapi...@gmail.com <javascript:>> 
> wrote: 
> > 
> > On Wednesday, August 3, 2016 at 11:46:43 PM UTC+8, Axel Wagner wrote: 
> >> 
> >> True, but it would still be just the same loop, it wouldn't actually be 
> >> significantly faster. And you'd need to put quite some machinery into a 
> >> pretty rarely used functionality, which means it also wouldn't be 
> cleaner. 
> >> 
> >> The thing is, that the memory representation of []T and []J, with J 
> being 
> >> an interface type, is very different form each other and differs also 
> for 
> >> each (T, J) pair, AIUI. So you can't really efficiently generalize 
> this. The 
> >> only thing it could possibly safe you, is writing the actual loop and 
> in 
> >> general go doesn't really do this kind of tradeoff (saving small 
> amounts of 
> >> trivial work by complicating the language and -implementation). 
> > 
> > 
> > so the copy buitlin function is not essential? 
>
> Correct. 
>
> Although it is worth noting that, in the absence of significant 
> compiler optimizations that the gc compiler does not currently 
> implement, the copy builtin can be much more efficient than the 
> ordinary user written loop; see 
> https://golang.org/src/runtime/memmove_amd64.s.  That is not true of a 
> function that converts from []T to []interface. 
>
> Ian 
>


Enabling user to do conversion from []*T    to    []*U   (the slices 
contain pointers) would be easy, doing a slight modification in the 
compilers.
We did tricks like this already in modified versions of go


Enabling user to do conversion from []T  (T is arbitrary not just fixed 
size type)   to   []interface would be possible with a deep modification 
involving linkers and other stuff (that I don't understand very well).

Dealing with []T when T is an interface would be nightmare difficult and I 
don't even know where would I begin

i believe in go experts they are more than capable to deal with this

-- 
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