It seems to me that what you are proposing with “implements” is not really a 
replacement for contracts. It would do something that contracts don’t (unify 
operators and methods), and it wouldn’t do nearly all of what contracts do 
(clearly define what is expected of type parameters across a wide range of 
possible operations).

As I understand it, the most important function of contracts is to produce 
sensible error messages (as opposed to the ones that C++ templates have become 
infamous for). If it weren’t for that, we could just leave type parameters 
unconstrained, and let the generic function’s body be its own contract. If the 
function uses <, the types passed to it must support <…

Andy

> On Oct 19, 2018, at 1:15 PM, Eric S. Raymond <e...@thyrsus.com> wrote:
> 
> 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.
> -- 
>               <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.

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