Skip to content
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

Iterating stacks without using pop #493

Closed
josepharhar opened this issue Oct 25, 2022 · 2 comments
Closed

Iterating stacks without using pop #493

josepharhar opened this issue Oct 25, 2022 · 2 comments

Comments

@josepharhar
Copy link

In whatwg/html#8199 I'm creating a stack as defined in infra here: https://infra.spec.whatwg.org/#stack
However, infra says that you must not use for each and instead use while and pop for iterating. If I must use while and pop to iterate over a stack, that means I have to pop everything off of the stack and then rebuild it in order to get it back to the way it was...? I just want to iterate over the stack without modifying it. Is that possible?

@domenic
Copy link
Member

domenic commented Oct 26, 2022

It sounds like you're inspecting values that are not at the top of the stack. In that case, it's not really a stack, it's just a list. So you should use the list type?

@josepharhar
Copy link
Author

Ah I should have thought of that, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants