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

Define local (and global) function/variable scoping/recursion rules #30

Open
dylex opened this issue Sep 20, 2009 · 0 comments
Open

Define local (and global) function/variable scoping/recursion rules #30

dylex opened this issue Sep 20, 2009 · 0 comments

Comments

@dylex
Copy link
Collaborator

dylex commented Sep 20, 2009

There are many possibilities for block assignment semantics. Ideally I would like expression blocks and the top level to basically follow the same rules (possibly modulo overloading). With most options there is a problem of premature variable references, before they're assigned. Basically they can be treated as if they are void or don't exist, much as we do now.

One extreme is that no shadowing is allowed and everything has scope everywhere. This could potentially make for very prickly code. The other extreme is that everything has scope strictly downwards, except for consecutive function definitions which also have scope within their group (for mutual recursion). This eliminates the premature reference issue, but is rather restrictive.

My current proposal is this:

  • Functions are arbitrarily recursive and all are in scope throughout their block. Multiple definitions are overloads or illegal.
  • Variables have scope strictly downward. Shadowing is allowed accordingly.
    In this case, premature references are always indirect (variable 1 calls function 3 refs variable 2; variable 2 calls function 1 calls function 4 refs variable 3).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant