Go Proposal: first-class support for sorting slices
1–10 of 105 posts
Re: Go Proposal: first-class support for sorting slices
#2Re: Go Proposal: first-class support for sorting slices
#3Brad is correct, the current approach is tedious.
Re: Go Proposal: first-class support for sorting slices
#4Since when did Go use Github for official proposals? Does it also use the Github repo for official development or is it still just a mirror?
Go "partly" uses GitHub. The git repo is a mirror, and code review / pull requests is done through Gerrit, but the issue repo is the official one.
Re: Go Proposal: first-class support for sorting slices
#5Re: Go Proposal: first-class support for sorting slices
#6Re: Go Proposal: first-class support for sorting slices
#7So the current approach is providing some popular functions which would normally require generics to implement as built-ins?
I'm thinking things like min/max, which are really distracting and are concepts that are more easily expressed as a concise function rather than an explicit loop.
Re: Go Proposal: first-class support for sorting slices
#8So the current approach is providing some popular functions which would normally require generics to implement as built-ins?
Re: Go Proposal: first-class support for sorting slices
#9That interface{} parameter makes me cringe, but it makes sense.
Let's talk about the fact that functions in Go could support type parameters in signatures , something like :
func Map(slice []V,func(element V)W)[]W {
// ...
}
What we have here is a guarantee that at compile time, this code is safe. We didn't introduce generics, slice is a Go slice of V and the result is a go slice of W.The code should then be used this way :
result := Map([]string{"a","b"},
func(e string)string{ return e+"foo" } )
This is completely type safe, no reflection is used, the compiler knows all the types at compile time and no generic type was introduced. This is a good trade off and merely syntactic sugar that would enable developers to get rid of interface {} parameter + type assertions.Re: Go Proposal: first-class support for sorting slices
#10That interface{} parameter makes me cringe, but it makes sense.
Go needs functions that support parametric types for collections. I'm not even talking about generics here as user defined types. Let's forget about generics or "the ability for developers to implement their own type safe containers". Let's talk about the fact that functions in Go could support type parameters in signatures , something like : func Map (slice []V,func(element V)W)[]W { // ... } What we have here is a…