On Wednesday, September 12, 2018 at 10:56:04 AM UTC+2, ohir wrote:
>
> On Tue, 11 Sep 2018 18:22:12 -0700 
> Patrick Smith <pat42...@gmail.com <javascript:>> wrote: 
>
> > I'm fairly sure there's no way to write Min, but perhaps someone can 
> prove 
> > me wrong? 
>
> Within "Craftsman Go Generics" proposal its trivial: 
>
> func Min(a, b T) T { 
>   for type switch { 
>   case T func(T) Less(T) T: 
>       return a.Less(b) 
>   } 
>   if a < b { 
>        return a 
>   } 
>   return b 
> } 
>
>
What about:

func Min(type T) (a, b T) T {
try {
return a.Less(b)
} else {
if a < b {
return a
}
return b
}
}

`try` tries each block at compile time, and use the first block that 
compiles successfully.

Well, probably there are a lot of issue with this proposal.

> [...]


Manlio 

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