Artifacts: pull out a recursive function from a closure to a stand alone function#49755
Merged
KristofferC merged 1 commit intomasterfrom May 12, 2023
Merged
Artifacts: pull out a recursive function from a closure to a stand alone function#49755KristofferC merged 1 commit intomasterfrom
KristofferC merged 1 commit intomasterfrom
Conversation
Member
|
Just to check, it’s enough to add the override file parameter without moving the function definition to be top level, right? |
Member
Author
|
I dont actually know. I'll try it out. |
Member
Author
|
This suggests that it is not enough: julia> function f(x)
g(x) = x == 0 ? 1 : x * g(x-1)
return g(x)
end;
julia> @code_warntype f(5)
MethodInstance for f(::Int64)
from f(x) @ Main REPL[2]:1
Arguments
#self#::Core.Const(f)
x::Int64
Locals
g@_3::Core.Box
g@_4::Union{}
g@_5::Union{}
Body::Any |
Member
|
I did not know that! I’ll have to avoid using interior functions then. |
staticfloat
approved these changes
May 12, 2023
Member
Author
At least when they are recursive I guess. |
51 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Recursive closures have to be boxed and type inference gives up. This improves the load time of LLVMExtra.jl that calls into Artifacts at runtime.