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

Change list evaluation to collecting all pushed items on a new stack #2050

Merged
merged 3 commits into from
Jan 9, 2024

Conversation

RubenVerg
Copy link
Member

No description provided.

Copy link
Member

@lyxal lyxal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to add tests in InterpreterTests

@lyxal
Copy link
Member

lyxal commented Jan 9, 2024

I'll wait for user to have a check before merging

Comment on lines +103 to +104
val context = ctx.copy
context.clear()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could add a stack parameter to Context#copy to avoid having to clear later?

@ysthakur
Copy link
Member

ysthakur commented Jan 9, 2024

Can list elements still access what was on the stack before the list literal started executing? If not, maybe we could do something closer to the old code, except record the length of the stack before each element starts executing so we can pop the appropriate number of elements? But that would get messed up if you popped something that was on the stack already and pushed something else (e.g. 3 #[ 2 + #]).

Maybe if we could make a child context that only uses the parent context's when its own stack runs out of elements? But that's not how child contexts work right now

@RubenVerg
Copy link
Member Author

@ysthakur lxyal and I agreed that allowing access to the outer stack leads to code that's hard to decide what should happen such as your example, so we opted for using a separate, empty-by-default stack. Maybe an alternative could be a parent stack that's read-only, so for example 3 #[1 + #] would use the 3 but not pop it from the stack. That however seems much harder to implement, and it doesn't seem that useful. If you want to access things from the outer stack, use the primitives that build lists

Copy link
Member

@ysthakur ysthakur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, makes sense then. LGTM

@ysthakur ysthakur merged commit 8ef5066 into version-3 Jan 9, 2024
8 checks passed
@ysthakur ysthakur deleted the v3-lists-with-more-things-on-the-stack branch January 9, 2024 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants