Re: [go-nuts] How to cast a multi-value?

2021-05-19 Thread Martin Leiser
Assigning string values to string values or byte[] to byte[] does not require additional memory allocation. But conversion between string and byte[] does so most of the time, because the underlying array of a string is immutable, versus the mutable of a byte[]. Encapsulating the type cast

Re: [go-nuts] Type parameters syntax... Can it be improved?

2021-03-25 Thread Martin Leiser
Ian Lance Taylor schrieb am Dienstag, 23. März 2021 um 23:22:51 UTC+1: > On Tue, Mar 23, 2021 at 3:19 PM atd...@gmail.com > wrote: > > > > Since, we also know the type of v, It would be infered from it. > > > > There is no variance, no dependent type... Meaning that the type of a Go >

Re: [go-nuts] No Generics - Type Binding on Imports

2021-03-22 Thread Martin Leiser
Am 22.03.2021 um 10:10 schrieb Martin Leiser: Am 21. März 2021 22:01:38 MEZ schrieb Ian Lance Taylor : On Sun, Mar 21, 2021 at 1:02 PM Martin Leiser wrote: ... import "container/list" stringlist type ElementType = string What if I want to have a list of lists

Re: [go-nuts] No Generics - Type Binding on Imports

2021-03-22 Thread Martin Leiser
Am 21. März 2021 22:01:38 MEZ schrieb Ian Lance Taylor : >On Sun, Mar 21, 2021 at 1:02 PM Martin Leiser >wrote: >> >> I think so. But How? Remember we need to do two things: >> >> - A way to define type parameters. >> >> - A way to bind the ty

[go-nuts] No Generics - Type Binding on Imports

2021-03-21 Thread Martin Leiser
" yet, but it should be possible to add this for typical functional libraries such as "sort.go <https://golang.org/pkg/sort/>".    - type bindings my even be transitive, if the binding type is itself a exported interface type. So the a full fledged proposal may end up a

Re: [go-nuts] [generics] notes on adding generics to a package

2021-02-08 Thread Martin Leiser
xis generic collections are the far more important aspect than functional libraries containing "Min" and "Max" functions. And your writing was all about collections too. Thank a lot for Your suggestions! Martin Leiser On Sun, Feb 7, 2021 at 9:20 PM Martin Leiser <mailt

Re: [go-nuts] [generics] notes on adding generics to a package

2021-02-07 Thread Martin Leiser
he types you actually want to use with them with. It is a simple "opt in" approach. You add a type binding on import, that's it. For the "generic" type in the package: Give a name to your types, which helps for readability anyway. And big thanks for your good writeup of the ex