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
add Stack.drop #10789
add Stack.drop #10789
Conversation
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 a useful proposal, I'm Approving, but indeed that looks like post-freeze material.
(I'm not sure whether the ice age will thaw off before or after the 5.00 release, so I just added a post-freeze
milestone.)
ping @gasche, I rebased on trunk and I believe it can be merged :) |
We require stdlib changes to be approved by two maintainers instead of one.(cc @Octachron, @nojb) |
I changed |
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.
LGTM
I am wondering though if drop : 'a t -> int -> unit
may be more generally useful ?
@nojb, fixed !
From the result I get on sherlocode, people seem to drop a single element most of the time. |
Agreed. The current API gives no facilities for pushing N elements at a time or popping N elements at a time, so dropping N elements at a time doesn't make much sense to me. |
Makes sense, the PR diff looks good and it has two approvals. Merging. |
Hi,
This PR adds a
val drop : 'a t -> unit
function to theStack
module.It behaves as
Stack.pop
except that it returns()
instead of the topmost element.This is useful when you're e.g. writing a WebAssembly interpreter. :)
More seriously, Sherlocode shows 118 results when searching for
ignore (Stack.pop
and there are probably more - IIRC Sherlocode doesn't index all opam packages so I bet the real number is higher.With the feature freeze, I wasn't sure about when this can be merged. I used
@since 5.00
, let me know if this should be changed.