Quoting robert engels (2018-10-18 15:22:36)
> Can you explain this a bit more, I must be missing something. Using the 
> example:
>
> func F(a,b type T like(int,X)) {
>   if a<b {
>     ...
>   }
> }
>
> How do you pass a struct to F because < isn’t valid on structs ???
>
> Which is why I proposed that < maps to Less() and then the primitives 
> simplicity implement these various methods, and user defined structs MIGHT.
>
> That way you write the code using Less(), and it works with primitives as 
> well.

This is what I was getting at; simply making the operators correspond to
methods is a well-known and fairly straightforward solution to the
problem, and it seems like the idea proposed in this thread is much more
complex.

Once you allow operators to simply correspond to methods, you can just
worry about how to abstract over methods, which you can do with
interfaces. My proposal outlines a variant of this that is fairly
simple, yet (once adding something like operator overloading) is still
able to handle every single example in the draft.

You can either give the primitive types methods, or allow methods to
override operators; both approaches work.

Burak, apologies if I've misinterpreted your own line of thinking.

-Ian

-- 
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