On Tue, Aug 1, 2017 at 2:43 PM, roger peppe wrote:
> On 1 August 2017 at 19:33, Josh Humphries wrote:
> > On Tue, Aug 1, 2017 at 11:44 AM, roger peppe wrote:
> >>
> >> On 1 August 2017 at 13:57, Josh Humphries
On 1 August 2017 at 19:33, Josh Humphries wrote:
> On Tue, Aug 1, 2017 at 11:44 AM, roger peppe wrote:
>>
>> On 1 August 2017 at 13:57, Josh Humphries wrote:
>> > Although that solution creates a heap-allocated tmp for every
On Tue, Aug 1, 2017 at 11:44 AM, roger peppe wrote:
> On 1 August 2017 at 13:57, Josh Humphries wrote:
> > Although that solution creates a heap-allocated tmp for every element in
> the
> > slice. Using an interface, the value will be inlined instead
On 1 August 2017 at 13:57, Josh Humphries wrote:
> Although that solution creates a heap-allocated tmp for every element in the
> slice. Using an interface, the value will be inlined instead of
> heap-allocated if it fits without boxing (so most primitive types and
>
On Tue, Aug 1, 2017 at 2:58 PM Josh Humphries wrote:
> Using an interface, the value will be inlined instead of heap-allocated
if it fits without boxing (so most primitive types and pointer types won't
need heap allocation).
This was true some years ago, but it is no
Although that solution creates a heap-allocated tmp for every element in
the slice. Using an interface, the value will be inlined instead of
heap-allocated if it fits without boxing (so most primitive types and
pointer types won't need heap allocation).
*Josh Humphries*
jh...@bluegosling.com
FWIW, you don't have to use Interface to do the swap:
https://play.golang.org/p/O8lGJGGOXP
On 31 July 2017 at 15:18, eZio Pan wrote:
> Hello,
> I want to build a "universal slice reverser" with reflect.MakeFunc. But I
> don't know how to get a copy of reflect.Value's
You have to use a temporary to swap the values:
tmp := a.Interface()
a.Set(b)
b.Set(reflect.ValueOf(tmp))
*Josh Humphries*
jh...@bluegosling.com
On Mon, Jul 31, 2017 at 10:18 AM, eZio Pan wrote:
> Hello,
> I want to build a "universal slice reverser" with
On Mon, Jul 31, 2017 at 4:18 PM eZio Pan wrote:
> My code return [7 6 5 5 6 7], but excepting result is [7 6 5 4 3 2]
https://play.golang.org/p/yraJZFDjS3
--
-j
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To
Hello,
I want to build a "universal slice reverser" with reflect.MakeFunc. But I
don't know how to get a copy of reflect.Value's underlying value, which
make result not correct.
Here is the code:
package main
import (
"fmt"
"reflect"
)
func reverse(in []reflect.Value) (out []reflect.Value) {
10 matches
Mail list logo