Most of the code I'd write with generics would take a func or something satisfying an interface to set the operations if necessary. I'd use type lists as a handy way for the user to default those to operators. Interface literals and lambdas would be just as useful here. I probably wouldn't bother writing a min that takes a comparator but not having min/max has never bothered me as much as not having things like Tree and Queue.
Type lists do seem like a really good idea but one that isn't quite fully polished yet. If it's left out of version 1 of generics and everything else is implemented as is, that would still be incredibly useful. Even if that only covers 90% of the problem that's still a lot. Also +1 on requiring constraints and predeclaring any. On Wed, Aug 5, 2020 at 10:40 AM Tyler Compton <xavi...@gmail.com> wrote: > > On Wed, Aug 5, 2020 at 1:07 AM Jan Mercl <0xj...@gmail.com> wrote: >> >> It's not supposed to be anything special whatsoever. Just like number >> zero or an empty set is not some kind of an exception. It's just you >> cannot have any reasonable set theory without it. > > > I think it's fair to say that `interface{}` is somewhat special in practice > because it acts as an escape hatch from the type system when necessary. No > other interface is capable of being satisfied by values of all types. I > assume that the `error` interface is pre-declared because it's a very common > interface used across almost all Go code. If `interface{}` is to become even > more common than it is thanks to generics, I think it could be reasonable to > follow the same thinking. > >> Go programmers do avoid casting because Go has no casting. That word >> or its stem doesn't even appear in the language specs. > > > Something tells me you knew Carla was referring to type assertions. > > > -- > 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/CAA%3DXfu0c-BqTt6vOjbE9ezur0nNNFCSBhgs%3DPFrEUBPASziinw%40mail.gmail.com. -- 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/CANG3jX%2BOWf3usTE%3D7nAXVkardPRd4-ypgtQix6Ean18pTuO6cQ%40mail.gmail.com.