Is that really true though? You can have one package that defines min/max for 
the built-in types (because it uses operators), and then one that uses 
method(s) Less() and Equals() that works with generics.

A similar technique can be used in sorting.



-----Original Message-----
>From: David Riley <fraveyd...@gmail.com>
>Sent: May 31, 2019 9:05 AM
>To: Robert Johnstone <r.w.johnst...@gmail.com>
>Cc: golang-nuts <golang-nuts@googlegroups.com>
>Subject: Re: [go-nuts] Go 2 generics counterproposal: giving up restricting 
>types
>
>Because Min and Max are very good and simple indicators of whether the 
>mechanism is generic enough to handle a fairly common idiom: small functions 
>for similarly behaved items, say comparable items, which are annoying and 
>repetitive to write for every data type which might support the operation (not 
>to mention the fact that increases the surface area for errors).
>
>It's also worth noting that if Min and Max can't be written in a generic 
>system, it's likely that Sort can't, either.
>
>If the purpose of a generic system is to reduce repetitive code in a readable 
>way, it's probably not doing its job very well if it can't do Min and Max.  
>They're good canaries.
>
>
>- Dave
>
>
>> On May 31, 2019, at 9:06 AM, Robert Johnstone <r.w.johnst...@gmail.com> 
>> wrote:
>> 
>> Hello,
>> 
>> I'm not sure that Min and Max need to be in the 80%.  It's annoying to write 
>> them repeatedly, but they are also very short.  The place where I typically 
>> miss generics is larger chunks of code, such as concurrency patterns.  I'm 
>> certain others are looking at datatypes.  Why do Min and Max need to be in 
>> the 80%?
>> 
>> Robert
>> 
>> 
>> On Thursday, 30 May 2019 14:26:34 UTC-4, Ian Lance Taylor wrote:
>> One of my guidelines for an acceptable generics proposal is that 
>> people can write Min and Max.  Your proposal admits that it doesn't 
>> permit that.  I think that is a problem.  I'm fine with the general 
>> idea of "do 80% of the job" but in practice people really do want to 
>> write Min and Max.  I think they are part of the 80% that needs to be 
>> handled, not the 20% that can be omitted. 
>> 
>> -- 
>> 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.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/e91e761e-92cd-452a-a387-e0741ebacd66%40googlegroups.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.
>To view this discussion on the web visit 
>https://groups.google.com/d/msgid/golang-nuts/A5807C0F-B951-45A1-9EBE-00629FE40B22%40gmail.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/176439122.1772.1559317546587%40wamui-hyena.atl.sa.earthlink.net.
For more options, visit https://groups.google.com/d/optout.

Reply via email to