Skip to content

Conversation

@xal-0
Copy link
Member

@xal-0 xal-0 commented Nov 27, 2025

If a method we precompile instantiates a closure struct, and there is a single compileable signature for the closure method, we can compile the closure method with few downsides.

For example:

f(x::T) where {T <: Number} = y::T -> x+y
precompile(f, (Int,))

f(1)(2)

Before, the closure method would not get precompiled, resulting in --trace-compile output:
precompile(Tuple{Foo.var"#f##0#f##1"{Int64, Int64}, Int64})

This idea was motivated by trying to make the REPL precompile script more "static". Creating a task with @task or @async expands into a no-argument lambda, which won't get precompiled with the containing method.

If a method we precompile instantiates a closure struct, and there is a single
compileable signature for the closure method, we can compile the closure method
with few downsides.

For example:
```
f(x::T) where {T <: Number} = y::T -> x+y
precompile(f, (Int,))

f(1)(2)
```

Before, the closure method would not get precompiled, resulting in
`--trace-compile` output:
`precompile(Tuple{Foo.var"#f##0#f#JuliaLang#1"{Int64, Int64}, Int64})`

This idea was motivated by trying to make the REPL precompile script more
"static".  Creating a task with `@task` or `@async` expands into a no-argument
lambda, which won't get precompiled with the containing method.
@Keno
Copy link
Member

Keno commented Nov 27, 2025

Seems fine, but wouldn't this be better handled by understanding the edge intrinsic that we added (I think) for juliac purposes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants