Hi, 

I'm reading the new typechecker source code of go compiler(under directory 
cmd/compile/internal/types2), during the initialization process, 
universe.go registers an implicit interface "comparable" inside function 
defPredeclaredComparable 
<https://github.com/golang/go/blob/e8b82789cda6c9d9e3dfc9a652b4d7a823b834f2/src/cmd/compile/internal/types2/universe.go#L199>,
 
I know it's supposed to be used for type comparison 
<https://golang.org/ref/spec#Comparison_operators>but failed to find where 
and how this interface and related method "==" is used. 

In predicates.go 
<https://github.com/golang/go/blob/e8b82789cda6c9d9e3dfc9a652b4d7a823b834f2/src/cmd/compile/internal/types2/predicates.go#L86>
 there's 
a function 'Comparable" to check whether a type is comparable or not, but 
seems there's nothing to do with the interface.

And I don't understand the lookup logic for method "==" in type.go 
<https://github.com/golang/go/blob/e8b82789cda6c9d9e3dfc9a652b4d7a823b834f2/src/cmd/compile/internal/types2/type.go#L465>
 neither, 
how could an Interface type have method named "=="?

I searched a lot from the code base but failed to find the answer, could 
anybody kindly give me some clue?

Thanks a lot :-)

-- 
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/6a58f1e4-4f52-4a48-8a64-68b5a92c8d35n%40googlegroups.com.

Reply via email to