On Wed, Jun 17, 2020 at 1:19 PM Hal <hwang....@gmail.com> wrote:

> * the syntax defining generic function is verbose on purpose (type
> keyword), not only for clarification, but also a remind of the cost and
> complexity behind generics
>

I don't know where this idea is from, but it's not accurate. The type
keyword is there to resolve a syntactical ambiguity: Without it, you
couldn't tell if `func F(A) (B)` is a function taking an A and returning a
B, or a generic function with type-parameter A and argument B.

The design draft actually opts to *not* be overly verbose, e.g. by omitting
the `type` keyword and constraints in method receivers of generic types.

* normal parameter list does not support default type, to be consistent,
> type parameter list should not either
>

I think it's fair to say that there is a semantical asymmetry here, in that
while there is a natural choice for a default constraint (namely being
unconstrained), there isn't one for parameter-types.

* multiple generic types without constraints can be written as "type T1,
> T2, T3 interface{}", not too much boilerplate anyway
>

I think in practice, something else would happen in many cases: Authors
would want a shorter way to write this, so packages would start declaring
`type Any interface{}` and use `Any` as a constraint - or use any of a
dozen or so names for the concept.

This isn't a deal-breaker to me, either way. But I don't really see a good
reason to forego this obvious small quality-of-life improvement. It's
pretty clear what it means to have no constraint anyway.


>
> --
> 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/a1315d89-febe-4bac-9246-b463dc097af1o%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/a1315d89-febe-4bac-9246-b463dc097af1o%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAEkBMfE5O3w_QT9_tjhpHpsh1-ZmAvu8-AcaJajFj6FE_AOuJw%40mail.gmail.com.

Reply via email to