You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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 cisa the locals of function b)
outer(n=1) is a function that returns n-level-up's scope.
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:
isa
chain. Default the scope of an inner function is a child of an outer one. (let thelocals
of functionc
isa thelocals
of functionb
)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.
The text was updated successfully, but these errors were encountered: