>
> FWIW, in my pseudo-interface description
> <https://blog.merovius.de/2018/09/05/scrapping_contracts.html> ...
>
You mention that comparable is a pseudo-interface, which means the type
supports the == and != operators. You say that comparable and the other
pseudo-interfaces are types.
So I should be able to write a function like
func f(x, y comparable) bool { return x == y }
And of course I can call it like so:
var x int
var y float32
f(x, y)
The problem is that this program seems to type-check, but it is invalid.
The == operator is specified to work on operands of the same type, and it
is being used on operands of different types.
This is the fundamental problem with using interfaces for operators.
And since we need some operators for generics (at least == and <), it is
also one of the fundamental problems with unifying interfaces and contracts.
--
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].
For more options, visit https://groups.google.com/d/optout.