New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
spec: receiver-curried method expressions #2280
Labels
Milestone
Comments
Adding dependency on issue #4081. And, adding to this bug the example I've given a few people now of when this is useful: type T struct { once sync.Once // guards setup of state state interface{} } func (t *T) initState() { t.state = .... } func (t *T) someMethod() { t.once.Do(t.initState) // because Do requires type "func()" // use t.state } Currently we have to either do: t.once.Do(func() { t.initState() }) ... which generates garbage each time, or give up on the zero value of T and instead make a constructor: func NewT() *T { t := new(T) t.initFunc = func() { t.initState } return t } func (t *T) someMethod() { t.once.Do(t.initFunc) ... } |
This issue was closed by revision 6e15683. Status changed to Fixed. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: