Re: [go-nuts] Is there a function in standard lib to convert []T to a []interface{}?

2016-08-05 Thread paraiso . marc
I guess the difference is that a builtin COULD be compile-time type safe. It could reject anything that is not a slice or an array, the same way append is type safe. Le mercredi 3 août 2016 17:51:44 UTC+2, Thomas Bushnell, BSG a écrit : > > On Wed, Aug 3, 2016 at 7:36 AM T L

Re: [go-nuts] Is there a function in standard lib to convert []T to a []interface{}?

2016-08-04 Thread Jesse McNelis
On Thu, Aug 4, 2016 at 3:33 PM, T L wrote: > > With some special memory optimizations for slice, I think it is possible to > make efficient conversions from []T to []interface. > For example, we don't need to convert every element in []T to interface{}, > we can just use

Re: [go-nuts] Is there a function in standard lib to convert []T to a []interface{}?

2016-08-03 Thread T L
On Thursday, August 4, 2016 at 12:16:37 AM UTC+8, Ian Lance Taylor wrote: > > On Wed, Aug 3, 2016 at 9:12 AM, T L > 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

Re: [go-nuts] Is there a function in standard lib to convert []T to a []interface{}?

2016-08-03 Thread charraster
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 > 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

Re: [go-nuts] Is there a function in standard lib to convert []T to a []interface{}?

2016-08-03 Thread T L
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

Re: [go-nuts] Is there a function in standard lib to convert []T to a []interface{}?

2016-08-03 Thread James Bardin
https://github.com/golang/go/issues/15209 On Wednesday, August 3, 2016 at 11:20:01 AM UTC-4, T L wrote: > > > > On Wednesday, August 3, 2016 at 10:53:34 PM UTC+8, Jessta wrote: >> >> On 4 Aug 2016 12:36 a.m., "T L" wrote: >> > >> > Often, I need converting a []T to

Re: [go-nuts] Is there a function in standard lib to convert []T to a []interface{}?

2016-08-03 Thread 'Axel Wagner' via golang-nuts
You probably don't want to actually call fmt.Println(s...) with s an []interface{}. Just do fmt.Print(s) instead. On Wed, Aug 3, 2016 at 5:20 PM, T L wrote: > > > On Wednesday, August 3, 2016 at 10:53:34 PM UTC+8, Jessta wrote: >> >> On 4 Aug 2016 12:36 a.m., "T L"

Re: [go-nuts] Is there a function in standard lib to convert []T to a []interface{}?

2016-08-03 Thread 'Thomas Bushnell, BSG' via golang-nuts
On Wed, Aug 3, 2016 at 7:36 AM T L wrote: > Often, I need converting a []T to []interface{} to use the []interface as > a variable length parameter. > But converting a []T for []interface{} in a for loop is neither clean nor > efficient. > If there was a builtin that did

Re: [go-nuts] Is there a function in standard lib to convert []T to a []interface{}?

2016-08-03 Thread 'Thomas Bushnell, BSG' via golang-nuts
Don't confuse variadic arguments with slice arguments, by the way. On Wed, Aug 3, 2016 at 8:20 AM T L wrote: > > > On Wednesday, August 3, 2016 at 10:53:34 PM UTC+8, Jessta wrote: > >> On 4 Aug 2016 12:36 a.m., "T L" wrote: >> > >> > Often, I need

Re: [go-nuts] Is there a function in standard lib to convert []T to a []interface{}?

2016-08-03 Thread 'Axel Wagner' via golang-nuts
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

Re: [go-nuts] Is there a function in standard lib to convert []T to a []interface{}?

2016-08-03 Thread Jesse McNelis
On 4 Aug 2016 12:36 a.m., "T L" wrote: > > Often, I need converting a []T to []interface{} to use the []interface as a variable length parameter. > But converting a []T for []interface{} in a for loop is neither clean nor efficient. > > So is there a function in standard lib

[go-nuts] Is there a function in standard lib to convert []T to a []interface{}?

2016-08-03 Thread T L
Often, I need converting a []T to []interface{} to use the []interface as a variable length parameter. But converting a []T for []interface{} in a for loop is neither clean nor efficient. So is there a function in standard lib to convert []T to a []interface{}? -- You received this message