76 points · by babawere · 13y ago · 39 comments
As someone who spent all of yesterday trying to figure out the best workaround for the lack of this functionality, I'm very happy to see this change.
edit: there's something "map"-ish here: https://code.google.com/p/go/source/browse/src/pkg/exp/itera...
As a language feature: not likely any sooner than Go 2.0, given everything that's been said on the issue, though I suppose if a way could be found to do generics that doesn't explode compilation time and doesn't involve syntax changes that would break any existing Go 1.x code, it might happen in a later 1.x release. Wouldn't hold my breath.
Via a preprocessor? Its already a thing: https://github.com/droundy/gotgo
One of Go's goals is a certain level of simplicity. The above point seems to state that generics don't fit that goal, but they are not precluded from a future version.
I take this to mean that since no language has every feature that anyone could possibly want, if generics are a requirement for your work, then Go does not fit the requirements.
Some potentially relevant material here - http://commandcenter.blogspot.de/2012/06/less-is-exponential... :
"Early in the rollout of Go I was told by someone that he could not imagine working in a language without generic types. As I have reported elsewhere, I found that an odd remark."
Why? 4 years on seems a long enough time to come to term with what Go is.
Does this still block forever?
package main
import "time"
func main() { go func(){ for {} }() time.Sleep(time.Millisecond) }
A busy loop is a sufficient way to emulate a heavy computation (e.g. applying effects to image files or compressing data) when it's not optimized out.
Been waiting for this forever...
http://play.golang.org/p/9J46QRHul1
They presumably would like to force you to use the return value if it is of type error.
On a side note, does any programming languages force you to use the return value of every function call?
The blog and comments here have summed this debate up nicely: http://uberpython.wordpress.com/2012/09/23/why-im-not-leavin...
Since the verbosity of error handling in Go is part of the debate here, are not FP languages often more concise? Is "concise-ness" really an issue?
_ = myFunc()
code. But it would be nice if the vet tool had a (optional) feature to warn you about ignored return values.