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
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
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
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
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
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
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"
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
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
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
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
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
12 matches
Mail list logo