-
Notifications
You must be signed in to change notification settings - Fork 29
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
Class Lifter #266
base: hkmc2
Are you sure you want to change the base?
Class Lifter #266
Conversation
What's the intended scheme regarding mutable local variables? FWIW, we should distinguish mutable from immutable variables. I intend to let When there are only immutable variables being captured, the scheme can be simpler. |
I don't distinguish between local variables that are mutated / not mutated for now. I intend to move every local variable that's referenced inside a nested class / function into a closure. Would it be better to add the immutable local variables to each class/function directly? P.S. seems I accidentally marked this PR as ready earlier, but it's definitely not. It's now marked as a draft. |
Added much more into to the the first comment. |
Ah, I see. I recall adding a modified version of the test that returns the output rather than printing it so I can use :expect. I think that's where the confusion is coming from. |
Co-authored-by: Lionel Parreaux <lionel.parreaux@gmail.com>
Co-authored-by: Lionel Parreaux <lionel.parreaux@gmail.com>
@LPTK OK, I've addressed everything. There's some minor things that I would like your opinion on, which are all in the unresolved comments. |
Thanks, I'll take a look. Maybe next week tho. In the meantime can you pls deduplicate all tests? |
Lifts classes and nested functions to the top-level.
Method
General idea: when functions have to capture local variables, we need to rewrite their parameter lists. For example:
is transformed into
Variables which are not mutated will be passed as a parameter directly.
TODO
Instantiate
does not work at allModules are not lifted properlyFor now we don't lift them at allg(unused)
is symbolically replaced.("lifting" curried functions is much easier than the lifting in general, so it can be done later)
Auxiliary Parameters
Classes can now have auxiliary parameters (IR only currently) with curried constructors.