To clarify on the type switches, would it have to be used like this:
type C interface {
type X, Y
}
func f(x X) X {
return x
}
func g[T C](v T) T {
switch v {
case X:
// to use v as an X
// we must convert
x0 := X(v)
x1 := f(x0)
// to use x1 as a T
// we must convert back
t := T(x1)
return t
case Y:
return v
}
}
And that the lack of a dedicated syntax to distinguish the case like
.[type] also means that you could no longer write
func h[T comparable](x, a, b T) {
switch x {
case a:
case b:
}
}
Regardless, all of these changes are fantastic!
On Thu, Aug 20, 2020 at 8:20 PM Robert Engels <[email protected]> wrote:
>
> I like it. Well done.
>
> > On Aug 20, 2020, at 9:22 PM, Jan Mercl <[email protected]> wrote:
> >
> > On Fri, Aug 21, 2020 at 2:28 AM Ian Lance Taylor <[email protected]> wrote:
> >
> >> To simplify the common case of a type parameter that has
> >> no constraints, we will introduce a new predeclared identifier “any”
> >> as an alias for “interface{}”.
> >
> > Anyone can write the declaration
> >
> > type any = interface{}
> >
> > today and possibly some people already do that. But in my opinion that
> > would, so far, not pass a code review within the Go project per se.
> > (It would definitely not pass my code review.)
> >
> > I don't like it and It makes me sad it is being proposed to become
> > officially blessed.
> >
> > --
> > 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 [email protected].
> > To view this discussion on the web visit
> > https://groups.google.com/d/msgid/golang-nuts/CAA40n-XDYjhoMXt%3DEP82EPSrrbmM2D4OsgtEwdx38h7HU5DwWw%40mail.gmail.com.
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/34314A4C-79B4-4913-9404-26EF1267115F%40ix.netcom.com.
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/CANG3jXL0fv2rptqrP6v5oPuih3HKA8yp12sRt8PJgC7dcSj%2BCA%40mail.gmail.com.