I follow the discussion about go generics for some time now, but never 
tried using them.

Your conclusion
> I struggled to grasp generics at the outset of this experiment. They are 
complex in a way that I haven’t encountered in a while with Go: I wasn’t 
sure when to reach for them and when to use another feature of Go.
is no surprise for me.

Adopting the "c++" or "java" style of generics, which dates back to Ada and 
experimentell languages before that is no good fit for golang in my 
opinion. I am working on a different approach not yet published. You may 
have a look 
in: https://github.com/leiser1960/importbinding/blob/master/README.md
I do not have a "go2go" implementation for it yet. It is way simpler, and 
there is no doubt when to reach for it.

The basic idea is: golang already has generic types: interface types. 
Simply constrain them to the 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 experiment.

Martin Leiser

Ian Lance Taylor schrieb am Freitag, 29. Januar 2021 um 23:13:21 UTC+1:

> On Fri, Jan 29, 2021 at 1:09 PM Ben Burkert <b...@benburkert.com> wrote:
> >
> > I wrote a blog post on my experience updating a package to use the
> > latest proposed generics feature with the go2go tool. My overall
> > impression is quite good as it was able to solve some existing
> > problems with the package. Thanks to Go team & gopher community for
> > all your work making generics happen!
> >
> > https://benburkert.com/posts/on-go2-generics/
>
> Thanks for the write-up!
>
> Ian
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/1f8db11d-56a7-4f16-b6b9-7c7b0b2fe822n%40googlegroups.com.

Reply via email to