On Thursday, January 6, 2022 at 9:44:05 PM UTC+8 tapi...@gmail.com wrote:

> On Thursday, January 6, 2022 at 9:40:49 PM UTC+8 Brian Candler wrote:
>
>> So to be more specific, I think you're asking why this code works:
>> https://gotipplay.golang.org/p/kuYzzx4EJY1
>>
>> Sorry, I made a mistake in interpreting the spec.  It also says:
>>
>> "The type set of the empty interface is the set of all types."
>>
>> Therefore, the type set of the intersection { int; any } is int - and 
>> hence f[int] is allowed.
>>
>> But the set of specific types 
>> <https://tip.golang.org/ref/spec#Structure_of_interfaces> is empty:
>>
>> "An interface specification which contains type elements 
>> <https://tip.golang.org/ref/spec#Interface_types> defines a (possibly 
>> empty) set of *specific types*. Loosely speaking, these are the 
>> types T that appear in the interface definition in terms of the form T, ~T, 
>> or in unions of such terms."
>>
>> The type set and the set of specific types can be different. Examples are 
>> given where one is empty and the other is non-empty:
>>
>> interface{ int; m() } // *[specific type]* int (but type set is empty 
>> because int has no method m)
>> interface{ int; any } // no specific types (intersection is empty) *[even 
>> though the type set is not empty]*
>>
>> *Items in [italics/brackets] are my additions*
>>
>
> > The type set and the set of specific types can be different
>
> This is true.
>
> > interface{ int; any } // no specific types (intersection is empty) *[even 
> though the type set is not empty]*
>
> I don't think this is true. In my opinion, the method set of specific 
> types of interface{ int; any } are both {int}.
>

sorry a typo:  it should be  

the method set and specific types of interface{ int; any } are both {int}.

-- 
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/24b410b6-879e-4f0b-9156-e6279f3bcb61n%40googlegroups.com.

Reply via email to