Re: [go-nuts] generics go2go Type List in Interface - Struct Type

2020-08-11 Thread 'Axel Wagner' via golang-nuts
Yes, it's intended. From the draft:

More precisely, the underlying type of the type argument must be identical
> to the underlying type of one of the types in the type list.


Type-lists match by underlying type of both argument and the types in the
type-list. As SantaHappy and SantaSad both have underlying type `struct{}`,
they are the same.

On Tue, Aug 11, 2020 at 10:59 PM Rich Moyse  wrote:

>
> Attempting to use a Type List in an Interface
> 
> to restrict the types allowed to instantiate a generic function (example
> in go2go ).  The Type List
> within the Constraint Interface (Santa) contains only one struct type
>  (SantaSad).  This struct type
> and a second, independent struct type (SantaHappy) both implement the
> Constraint Interface (Santa) specified as a type parameter for the generic
> function.  Given this situation, I expected the instantiation of the
> generic function with a type argument of the type (SantaSad), that appears
> in the Constraint's Interface Type List to succeed, which it does, and
> instantiating the generic function with the struct type, absent from the
> Type List (SantaHappy), to fail.  However, instead of failing, this second
> case succeeds.  Is this the intended behavior?
>
>
> --
> 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/44b6cb78-d143-437f-b4e0-f1cf8d642989n%40googlegroups.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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAEkBMfF5TThWSMZ4SEN_k79J5V1p6C-GD-uo96cM3Ud%3DkEybKA%40mail.gmail.com.


[go-nuts] generics go2go Type List in Interface - Struct Type

2020-08-11 Thread Rich Moyse

Attempting to use a Type List in an Interface 

 
to restrict the types allowed to instantiate a generic function (example in 
go2go ).  The Type List within 
the Constraint Interface (Santa) contains only one struct type 
 (SantaSad).  This struct type 
and a second, independent struct type (SantaHappy) both implement the 
Constraint Interface (Santa) specified as a type parameter for the generic 
function.  Given this situation, I expected the instantiation of the 
generic function with a type argument of the type (SantaSad), that appears 
in the Constraint's Interface Type List to succeed, which it does, and 
instantiating the generic function with the struct type, absent from the 
Type List (SantaHappy), to fail.  However, instead of failing, this second 
case succeeds.  Is this the intended behavior?


-- 
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/44b6cb78-d143-437f-b4e0-f1cf8d642989n%40googlegroups.com.