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

[Feature Request] Make inner functions access to all the variables defined outside. #131

Open
Withered-Flower-0422 opened this issue Feb 12, 2024 · 0 comments

Comments

@Withered-Flower-0422
Copy link

Withered-Flower-0422 commented Feb 12, 2024

From my own perspective, I still strongly ask for the inner function can access all the variables defined outside, like other languages do.

WHY
One important reason we need an inner function is that we want to keep some variables defined inside a function private, unable to access form outside.
But if we cannot access them even from inside, these variables are likely to be "dead"(unable to access via any means in a deeper inner function). That's what we don't want to see.

HOW
If we don't want any magic, we can do like this:

  1. Variables are looked up by isa chain. Default the scope of an inner function is a child of an outer one. (let the locals of function c isa the locals of function b)
  2. outer(n=1) is a function that returns n-level-up's scope.

Or, we can make it easier with some magic?

See details on Discord.

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