-
Notifications
You must be signed in to change notification settings - Fork 223
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
Implement set.update method #573
Conversation
The `update` method on the `set` is defined in the Starlark specification [1] but is not present in the starlark-go implementation. This change introduces this functionality. [1] https://github.com/bazelbuild/starlark/blob/master/spec.md#setupdate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this fix!
Fixes from @adonovan in PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again.
starlark/library.go
Outdated
switch v := arg.(type) { | ||
receiverSet := b.Receiver().(*Set) | ||
|
||
// factored out into a function so that the `defer` is scoped to this iterable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point; but the comment isn't necessary as the code speaks for itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fact that the defer
is in the function is obvious but the rationale is probably not so obvious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fairly common to call a function literal to reduce the scope of a defer.
The method update on the type
set
is available in the Bazel implementation of Starlark, but unfortunately not this Go implementation. This PR will augment theset
implementation to also support theupdate
method.