Re: [go-nuts] [generics] Issues with identifying the matched predeclared type

2020-07-08 Thread Steven Blenkinsop
On Wed, Jul 8, 2020 at 3:59 AM roger peppe wrote: > > That's another interesting syntax. I'm not sure whether there's any > particular advantage in mentioning the type parameter in each case, > although I guess it does mean that the syntax for multiple matches is > straightforward and can allow

Re: [go-nuts] [generics] Issues with identifying the matched predeclared type

2020-07-08 Thread roger peppe
On Wed, 8 Jul 2020 at 00:33, Steven Blenkinsop wrote: > On Tue, Jul 7, 2020 at 10:44 AM, roger peppe wrote: > >> >> In my description, there's no assumption that doing it over the type >> parameter implies a refinement of the previously set type constraints. In >> fact it definitely implies

Re: [go-nuts] [generics] Issues with identifying the matched predeclared type

2020-07-07 Thread Steven Blenkinsop
On Tue, Jul 7, 2020 at 10:44 AM, roger peppe wrote: > > In my description, there's no assumption that doing it over the type > parameter implies a refinement of the previously set type constraints. In > fact it definitely implies otherwise because (for example) if you know that > a generic type

Re: [go-nuts] [generics] Issues with identifying the matched predeclared type

2020-07-07 Thread roger peppe
On Tue, 7 Jul 2020 at 21:05, Tobias Gustafsson < tobias.l.gustafs...@gmail.com> wrote: > Den tisdag 7 juli 2020 kl. 16:45:21 UTC+2 skrev rog: >> >> On Tue, 7 Jul 2020 at 10:36, Tobias Gustafsson >> wrote: >> >>> Hi all, >>> >>> Thanks for the response on this subject! >>> >>> Yes, a kind of type

Re: [go-nuts] [generics] Issues with identifying the matched predeclared type

2020-07-07 Thread Tobias Gustafsson
Den tisdag 7 juli 2020 kl. 16:45:21 UTC+2 skrev rog: > > On Tue, 7 Jul 2020 at 10:36, Tobias Gustafsson > wrote: > >> Hi all, >> >> Thanks for the response on this subject! >> >> Yes, a kind of type switch over generic types is probably what I >> envision. There is a potentially nice symmetry

Re: [go-nuts] [generics] Issues with identifying the matched predeclared type

2020-07-07 Thread roger peppe
On Tue, 7 Jul 2020 at 10:36, Tobias Gustafsson < tobias.l.gustafs...@gmail.com> wrote: > Hi all, > > Thanks for the response on this subject! > > Yes, a kind of type switch over generic types is probably what I envision. > There is a potentially nice symmetry with the current runtime type

Re: [go-nuts] [generics] Issues with identifying the matched predeclared type

2020-07-07 Thread Tobias Gustafsson
Hi all, Thanks for the response on this subject! Yes, a kind of type switch over generic types is probably what I envision. There is a potentially nice symmetry with the current runtime type switches and type annotations that caught my eye (being aware of the fact that finding false patterns

Re: [go-nuts] [generics] Issues with identifying the matched predeclared type

2020-07-07 Thread roger peppe
How about something like this? Type switches A *generic type switch* allows a generic function to provide specialized behaviour based on its type arguments (for example to use a more efficient implementation for some types). A type switch refines the type of a type parameter. Cases match actual

Re: [go-nuts] [generics] Issues with identifying the matched predeclared type

2020-07-06 Thread Steven Blenkinsop
On Mon, Jul 6, 2020 at 6:29 PM, roger peppe wrote: > > I've also been playing around in this area. I've been trying something > similar to this approach: https://go2goplay.golang.org/p/sHko_EMhJjA > But this isn't ideal - note that we lose type safety when assigning back > to the generic hash

Re: [go-nuts] [generics] Issues with identifying the matched predeclared type

2020-07-06 Thread roger peppe
On Mon, 6 Jul 2020 at 17:46, wrote: > Hi! > > I've spent some time lately to try out the go2go tool and the new generics > proposal by converting a small hack I did some years ago for immutable data > structures (https://github.com/tobgu/peds) which, in it's current shape, > depends on code

Re: [go-nuts] [generics] Issues with identifying the matched predeclared type

2020-07-06 Thread Ian Lance Taylor
On Mon, Jul 6, 2020 at 9:46 AM wrote: > > I've spent some time lately to try out the go2go tool and the new generics > proposal by converting a small hack I did some years ago for immutable data > structures (https://github.com/tobgu/peds) which, in it's current shape, > depends on code

[go-nuts] [generics] Issues with identifying the matched predeclared type

2020-07-06 Thread tobias . l . gustafsson
Hi! I've spent some time lately to try out the go2go tool and the new generics proposal by converting a small hack I did some years ago for immutable data structures (https://github.com/tobgu/peds) which, in it's current shape, depends on code generation. There is nothing really mind bending