Re: [go-nuts] [generics]The ability to allow different length arrays and slices

2020-07-21 Thread benjamin . zarzycki
Clearly that's a workaround though. Like how you can copy a slice of bytes without calling copy by casting it to a string and then back to []bytes. It gets the job done, but it's weird and not obvious. On Wednesday, July 15, 2020 at 12:14:19 PM UTC-7, Axel Wagner wrote: > > Why not just accept

Re: [go-nuts] [generics]The ability to allow different length arrays and slices

2020-07-15 Thread 'Axel Wagner' via golang-nuts
Why not just accept slices only and expect the caller to add a `[:]`? It's not quite as ergonomic, but should have the same effect and we wouldn't need to add complexity to the design. On Wed, Jul 15, 2020 at 4:58 PM wrote: > Right now as I understand it, I would still have to write a different

[go-nuts] [generics]The ability to allow different length arrays and slices

2020-07-15 Thread hsoolien
Right now as I understand it, I would still have to write a different generic function for different length arrays, or one that accepted slices. as per: // Accept slices of T func someSliceFunc(type T)(s []T){ ... } // Accept a 1 member array of T func someArrayFunc(type T)(a [1]T){ ... } ... //