3 ms·
https://tip.golang.org/pkg/sort/#Slice https://tip.golang.org/pkg/sort/#Slice ouch compile time type safety... even Go maintainers have abandoned it. Go pundit
by inblueredgreen 10y ago
https://tip.golang.org/pkg/sort/#Slice https://tip.golang.org/pkg/sort/#Slice
ouch compile time type safety... even Go maintainers have abandoned it. Go pundits can't expect developers not to do the same thing in their own codebase at that point.
Can't wait for aliases though.
- bostik 10y agoThe ability to provide inline comparison function for Sort() is welcome. It's one of those infrequently needed language niceties that have (at least for me) made perl and python so slick to use. Sorting arrays of objects or small hashes, based on arbitrary properties/keys, is quite useful.
- yxhuvud 10y agoYou are not really responding to the comment you are replying to, though. Yes, being able to do custom sorting is nice, but no-one challenged that claim. The type system really doesn't look very nice when it won't even manage type safety in such a simple case as this. Also, compared to other languages that is in sort of a similar spot[* ], such as Swift or Crystal that both manage type safe custom sort functions, it looks even worse. [*] That is, modern languages that compile down to native code while having some basic way of avoiding manual memory management.