I agree that operators in contracts and the proposed generics don't seem to 
mesh well. Your proposal would enable the use of operators in interfaces in an 
easy way.


However, personally I think that perhaps we don't need operators at all. 
Suppose I was to implement a generic btrie or such today in Go1. How would I do 
it? I would use an interface for the data in nodes like this:

BtrieData interface {
    Equals(data BtrieData) bool
    Less(data BtrieData) bool
    AssignTo(target *BtrieData) error
}

No operators, just member functions.
The only downside to this is for primitive types which will need a wrapper 
types. Implementing such a wrapper type is pretty easy, and with generics, the 
compiler could likely optimize generic wrapper types. 

Seeing how complex the interaction between generics and operators would become, 
I would simply drop them an use interfaces as they are now as the contract 
type. For niw, I don't see what complelling benefits allowing operators in 
generic contracts would bring.

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to