-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
"generated function body is not pure" being too greedy? #19299
Comments
A counterpoint:
In this case the generator made a function (not sure if it's a closure, since |
And to round it out:
Here the generator definitely made and returned a closure. |
It can return a closure (value), although that seems rather pointless (it's just a less clear way of calling typeof and wrapping it in an object) It just can't define a new function (closure) as there's no environment for it to capture. |
I still don't quite understand. I assumed a
The "environment" it captures is defined in step 2, right? Oh wait, I can see that from this:
that the lowered AST already knows the type of the closure. So closures (and A couple of times, I have wondered if methods could store their higher-level |
So, in summary, the "magical" steps of lowering (closures and comprehensions/generators) can only occur for the function generator, not the generated code. Lowering of the generated code must be pure. Perhaps this also explains how Do you see this as limitation of the current implementation? Is there much desire for changing this (i.e. expanding generators/comprehensions and closures to generated functions)? |
OK, I agree that this issue is resolved, but it wasn't clear to me what "generated function body" was referring to (but after the fact I do see what that implied). I'm very amenable to making a clear docstring a la #19300 and preparing a PR myself if @vtjnash would grant me a few words of clarification/confirmation on what is going on. Particularly if my understanding of lowering as it stands is correct. Cheers Jameson/Stefan. |
OK I think my questions were answered elsewhere. Thanks! |
Re-opening to ask for a reconsideration of that won't fix tag, especially since Yichao suggests that it may be possible eventually #21094 (comment). |
This is definitely won't fix. I've reopened the linked issue, as it is possible we might find a way to fix it. |
I have received errors on master for StaticArrays and made this minimal example
Perhaps I'm completely wrong but isn't it the function generator that must be pure? I wasn't aware that the types of functions that could be generated were restricted in any way.
I'm curious if some code is being overzealous in asserting that the function generator has created a closure? Or please correct me if I'm mistaken.
The text was updated successfully, but these errors were encountered: