On Sat, Jul 18, 2020 at 4:00 AM Markus Heukelom
<markus.heuke...@gain.pro> wrote:
>
> Concerning only the current proposal, is there a reason why we shouldn't 
> allow specifying the parametric types for a whole bunch of functions / types 
> at once?
>
> Like:
>
> generic (type T) (
>
> func Average(value []T) {...}
> func Median(value []T) {...}
> // etc
> )
>
> generic (type T1, T2) (
>
> func Map(s []T1, func(T1) T2) []T2
> func BiMap(s []T1, func(T1) T2) []T2
> //...
> )
>
>
> All things within generic () would have the same type parameter signature. It 
> would be a bit similar to how var and const declarations work. It would 
> remove a lot of redundancy and parenthesis.
>
> To make things symmetric, a single generic function would have to be 
> specified with something like this
>
> generic (type T1, T2) func Map(s []T1, func(T1) T2) []T2.
>
> type Vertex generic (type T) struct {
>  Coords [3]T
> }


How do we instantiate these generic types and functions?  If a list of
generic type parameters is factored out, do we have to supply all of
them even if a particular function only uses one of them?

Also, while this may seem like a trivial question, how do we indent
within a generic block?

(To answer your question, we did actually look at syntactic approaches
along these lines for a while, but we eventually moved on to the ideas
presented in the design draft.  Not because this idea is terrible, but
because we felt the approach used in the design draft was a better fit
for the language.)

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/CAOyqgcW-Rv0EETKm-kmZ5niwn0NO5-GEe5jPTGKKyoHgoL_sQA%40mail.gmail.com.

Reply via email to