On Tue, Jun 16, 2020 at 1:54 PM Arnaud Delobelle
<arnaud.delobe...@sparx.co.uk> wrote:
>
> I noticed today the blog post about the revised Generics proposal.  What got 
> me excited is this extract at the start:
>
> The biggest change is that we are dropping the idea of contracts. The 
> difference between contracts and interface types was confusing, so we’re 
> eliminating that difference.
>
> To me the lack of orthogonality between contracts and interfaces was the 
> major issue with the previous proposal and I have been musing with ways of 
> resolving it for a while, so I am very pleased that the proposal is going 
> down this path!
>
> Last month I decided to write a post about a way of introducing Generics into 
> Go using interfaces,  which I called "Package Specialization".
>
> Headline features are:
>
> use interfaces to express parametric types;
> no new keyword;
> the only new syntax is “package specialization”: pkg(T=int, Y=*MyType).Func();
> generic code which doesn’t use the package specialization syntax is already 
> valid Go.
>
> The full post can be read here: 
> https://arnodel.github.io/marooned/go/generics/2020/06/06/go-spec2.html
>
> I was toying with the idea of submitting it here for feedback, to try to move 
> the discussion in that direction.  Well, I guess today's updated proposal 
> steals my thunder! Essentially this is the same idea, but with a different 
> manifestation in the language - I thought that submitting it anyway may 
> provide a useful comparison point to help gauge the updated proposal better.
>
> Note that sadly, I do not have much time to polish a proposal or to follow 
> discussions in general on this or other golang-related discussion lists, so I 
> apologize in advance if I am inadvertently re-hashing ideas that have been 
> put forward and dismissed in the past, or if my blog post is a little low on 
> detail (it was meant to be an exploration of a possible approach).

Thanks.  I hadn't seen that before.

A difficulty with package specialization is when you want to write a
List(List(int)).  That is, a List where each element of the List is a
List(int).  Or, when you want to write a transformation function as in
https://go.googlesource.com/proposal/+/refs/heads/master/design/go2draft-type-parameters.md#list-transform.
It would seem to require some modification of how imports work in Go,
and that leads into considerable complexity.  See also
.https://go.googlesource.com/proposal/+/refs/heads/master/design/go2draft-type-parameters.md#why-not-put-type-parameters-on-packages
.

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/CAOyqgcVS%3Dae90U51y_%2BN6a00Ve6UTK%3DNfqz38LhzuMSBDrXmZQ%40mail.gmail.com.

Reply via email to