-
Notifications
You must be signed in to change notification settings - Fork 17.6k
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
Proposal: add a builtin splice function for easier slice handling #14991
Comments
Regardless of its merits, the language is basically frozen at this time. Most proposals are around standard library modifications, and even then most are rejected because the standard library is also pretty frozen. The bar for language changes is high and must be supported with lots of data to support a proposal. Do you have data to support that a significant percentage of |
I doubt that's true. What's true is that append is currently the only sane way of removing elements from a slice, or inserting elements at an arbitrary position. |
Is splicing really that common of a task? There are use-cases, but is it a day-to-day need for the average programmer working on an "average" project? Even then, is it the only solution? Splicing usually implies that the order of elements in a slice matters, thus use of the "sort" package may be an alternative to many of these needs. Regarding the specifically proposed function signature: I'd argue that Go tends toward "i:j" semantics rather than "i:length" semantics. deleteCount is similar to "length" in this case, rather than establishing a "replacement window" that, I at least, would expect. |
I don't want to add more builtin functions. |
There is a way to add these without builtins. We all know it's name. But it 2016 rugp. 1 03:49 "Rob Pike" notifications@github.com rašė:
|
Closing. The language is frozen. |
This proposal is for adding a builtin splice function for adding/removing items in a slice:
While the builtin append function can do everything that a splice function can, its a lot trickier to use for anything other than append, even by experienced go users. Newcomers to the language struggle with simple tasks of slice modification, and there are a lot of posted questions about them. It doesn't help that a function named
append
is supposed to be used for removing items from a slice.On the other hand, people might be familiar with the splice function and its notation from other mainstream languages.
It doesn't seem like much, but it's a low hanging fruit that will help people new to the language.
The text was updated successfully, but these errors were encountered: