Skip to content

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

@dylex

Description

@dylex

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions