-
Notifications
You must be signed in to change notification settings - Fork 86
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
Named IIFE (immediately invoked function expression) optimized away #803
Comments
I wonder if (at least part of) the problem here is the fact that webppl doesn't bind the name of named function expressions in their body. e.g. (It's news to me that JS named function expressions do this.) |
I think named function expressions generally get misunderstood. Its often sufficient in practice to assign an anonymous function expression to a named variable and use that for recursion and I think this is the most common practice in webppl. It really comes down to the issue of assigning a name to an intermediate expression. |
When this is compiled, the factorial function is optimized away because it is invoked immediately. I believe it is because of the condition here:
https://github.com/probmods/webppl/blob/dev/src/transforms/optimize.js#L85
I think it is good to check if the callee has a name, because then it might be used for recursion.
The text was updated successfully, but these errors were encountered: