Ian Denhardt <i...@zenhack.net>:
> Quoting Eric S. Raymond (2018-10-19 16:15:25)
> > Ian Denhardt <i...@zenhack.net>:
> > > What would code making use of a `Sortable` type look like? If you can't
> > > actually use "implements <" to overload `<`, it's not clear to me what
> > > it would actually do?
> >
> > Be available to a Sort function.  That is, the requirement "Have a Less()"
> > would be replaced by "Have an implements-< method".
> >
> > How this is specified at the callsite is a separate question.  I can't
> > see any simpler way to do it than writing '<', but if anyone hates
> > overloading enough to invent a syntax they can do it ab nd
> > I won't complain.
> >
> > I'm saying I'd prefer that future to heavyweight contracts.  Surface
> > overloading is *not* the important thing about "implements"; having a
> > lightweight way to refer to typeclasses like "Sortable" is.
> 
> Ah, so are you just suggesting you'd be able to do (e.g.):
> 
> func SortSlice(type T implements <)(slice []T) {
>     // ...
> }
> 
> ..but not actually be able to redefine `<` for a user-defined type?

Something like that.  Only why require (type T implements <)?  The compiler
can figure out whether T implements < or not and throw an error if it doesn't.

Somewhere inside the generic Sort we'd need a way to say "plug in T's
implementation of < here."  That's the callsite I was thinking of.  The
simplest and most obvuius way to do that is to bite the operator-overloading
bullet and say "<", but I'm saying I could live with some magic syntax to
avoid that if the allergy to operator overloading is insuperable.

I'm in kind of a weird position here, because I want us to do the simplest
possible thing but recognize that there's allergy to it going around.
-- 
                <a href="http://www.catb.org/~esr/";>Eric S. Raymond</a>

My work is funded by the Internet Civil Engineering Institute: https://icei.org
Please visit their site and donate: the civilization you save might be your own.


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