-
Notifications
You must be signed in to change notification settings - Fork 1
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
Hoist functions #27
Comments
I'm not sure I understand: what happens with mutual recursion? |
Mutual recursion works. :P The idea is that both functions need to be defined before the first call. So,
works fine because the first call is made after both functions are defined. And since the body is evaluated only after both functions are in the environment, there are no problems. |
Looking at a piece of Javascript today: f();
var f = 5;
// f();
function f() {
console.log("Hello");
}
f(); The last line causes an error. This leads to a lack of locality of effects, which suggests that this might not be a good idea. If you wish you declare intent first, and then give the function bodies, you could easily move them to another file and import (when importing support actually arrives). |
Rejecting the idea. Can be better solved by imports when the time comes. (Some rationale at https://blog.vghaisas.com/hoisting-and-locality/). |
Hoist functions based on later definitions.
should work.
The text was updated successfully, but these errors were encountered: