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

Remove scope types #91

Merged
merged 2 commits into from
Sep 11, 2023
Merged

Remove scope types #91

merged 2 commits into from
Sep 11, 2023

Conversation

samestep
Copy link
Contributor

Previously we've had a special type called Scope to differentiate function-local Refs with different scopes, so that they can't be assigned to each other willy-nilly, and so that we can prevent usage of a reference when it goes out of scope. This PR removes those so now all Refs with the same inner type are treated the same.

The reason for this is that we need to treat scopes slightly more flexibly in #86; specifically, if you Select on two Refs, it's unclear which scope the result should have. It can't have its own new scope, because having its own scope means that it can be Resolved later. But that problem goes away if both Refs are just the same type. Also, this removes an additional pass in transposition where we would need to keep track of what variables need to have new scope types added for them: with no scope types, that sort of self-referential-ness goes away.

The reason we originally had scope types at all was because it seemed like differentiating them at the type level would make scopes easier to validate. But we already have to validate scopes of other kinds of variables, and this doesn't really seem different. All you need to do is ensure that Refs introduced in a block get resolved later in that same block. Then for derived Refs, just have them point to the most recently defined non-derived Ref that they use; this arises in Select, for instance. We already use this most-recently-defined idea in rose-web for normal variables to deal with lazily-defined literals. Also, note that this behavior for Select constrains us to have scope nesting be properly matched: for instance, it wouldn't work to define two Refs and then later resolve them in non-reverse order, because then a Selected Ref would only get invalidated after the second one rather than the first one.

@samestep samestep mentioned this pull request Sep 11, 2023
@samestep samestep merged commit bba2b3f into main Sep 11, 2023
@samestep samestep deleted the scopeless branch September 11, 2023 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant