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

Improve the method of typecheck blocks #1

Open
jparoz opened this issue Oct 2, 2023 · 0 comments
Open

Improve the method of typecheck blocks #1

jparoz opened this issue Oct 2, 2023 · 0 comments

Comments

@jparoz
Copy link
Owner

jparoz commented Oct 2, 2023

A better model for typechecking blocks might be to introduce a type Closure which is similar to the current Scope (or SubScope). This contains all the locals declared, globals assigned, and globals constrained in the block. Typechecking a block returns this closure object; this can then be applied to the parent scope (closure), or interpreted similar to the current Scope.

Note that the same variable name could appear as a local, assigned and constrained global, e.g.:

do
    local _ = x .. "foo"
    x = 333
    local _ = x + 5
    local x = "sss"
end

This is valid, but the x before and after the global assignment, as well as the local x, are all distinct in view of the closure.

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

No branches or pull requests

1 participant