-
Notifications
You must be signed in to change notification settings - Fork 0
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
Get lambda lifting right #34
Comments
I think stating it to be a mess without even raising a concern, analyzing the problem properly and suggesting a solution is not really appropriate. You should keep those comments to yourself and rather remain constructive. That being said, I would like to give the reasoning behind the current implementation: We find all free variables but also all `lonely´ literals to construct the argument list of the lambda abstaction to be created. That way, no (stateful) function executes before something gets applied to the lambda. This makes sense because this is what a contextified execution is all about. The problem seems to be now that certain ohua-internal functions exist that would fall into the category of having
A solution now could certainly be to just filter out function literals in general. This would work for as long as we do not support stateful functions as first class citizens in the algo language. To support it, we could just always say that the selection should prefer other types of literals first and only take function literals if they are the only type of literal in the argument list. Looking at the commit history, I can see that Function Literals were introduced into the code without a proper idea of what to do with them in case of lambda lifting: see commit 8a66be136dd67cb21f4fafa77d459b0234f2a95c |
Lambda lifting is kind of a mess right now.
I just had to change it so that it doesn't recognize function references as literals, because for
unitFn
it is important that the reference stays as as a direct argument to the function, due to how code generation works in the backend. The same is actually true fornth
, where the two indices have to remain literals. I'd prefer not having to teach the lambda lifting pass which functions need literal inputs and which don't.I don't yet know how this can be improved.
It could also mean that the current representation of the execution graph is insufficient or at least not well suited for
nth
and the like.The workaround I am employing for the function references right now might not be available always, but for now its the easiest way.
I'm simply putting this issue out there so that we don't forget that it exists. For now this is low priority.
The text was updated successfully, but these errors were encountered: