On Sun, Feb 2, 2020 at 7:08 PM Steve Roth <st...@rothskeller.net> wrote: > > What I'm suggesting may be covered by generics if and when they ever happen, > but considering that generics are a breaking change and are years away at > best, they are not relevant to the evaluation of a small, backward-compatible > change.
The current generics design draft (https://go.googlesource.com/proposal/+/master/design/go2draft-contracts.md) is not a breaking change. It may be years away, but that isn't a strong argument for making a change that would be unnecessary if we had generics. As far as I can tell, you can already do what you want in Go by using a map. And in fact a map would be even more type safe, as in your suggestion there is nothing that forces the index of a []*Event to be an EventID. Of course a map would have different performance characteristics. All in all this seems like a fairly subtle change, that introduces an additional implicit type conversion to the language. Or, perhaps, treats the first value in a range clause as an untyped integer, although it is not a constant. It seems to me that this in effect adds another inconsistency to the language, which means another special case that people have to learn. That doesn't sound like a great idea. It would be better if it could be a specific effect of a general rule, but I don't see how to do that. Ian -- 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/CAOyqgcX2dOLHwT6jn5DYaa5xMCq8kirnaSvEK946a1BqHWtuaw%40mail.gmail.com.