Skip to content
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

Support @opaque Tuple{T,U...}->RT (...)->... syntax for explicit arg/return types #54947

Merged
merged 1 commit into from
Jul 4, 2024

Conversation

topolarity
Copy link
Member

This gives users a way to explicitly specify the return type of an OpaqueClosure, and it also removes the old syntax @opaque AT ... in preference of @opaque AT->_ ...

@topolarity topolarity requested a review from Keno June 26, 2024 17:51
@topolarity topolarity changed the title Support opaque Tuple{T,U...}->RT (...)->... syntax for explicit arg/return types Support @opaque Tuple{T,U...}->RT (...)->... syntax for explicit arg/return types Jun 26, 2024
@topolarity topolarity force-pushed the ct/opaque-closure-rt branch 2 times, most recently from 377b162 to a4a5912 Compare June 26, 2024 18:00
src/julia-syntax.scm Outdated Show resolved Hide resolved
This provides a means to explicitly specify the return type of an
OpaqueClosure, which previously was not possible without calling
`jl_new_opaque_closure` directly.

As a result, `@opaque AT (...)->...` is no longer an allowed form
to define an OpaqueClosure. Instead `@opaque AT->_ (...)->...`
should be used.
@topolarity topolarity force-pushed the ct/opaque-closure-rt branch 3 times, most recently from 3928aa1 to cd74005 Compare June 27, 2024 15:05
@topolarity
Copy link
Member Author

This should be ready for review again

@topolarity
Copy link
Member Author

@Keno If there are no complaints, I plan to merge this tomorrow

@topolarity topolarity merged commit a5f0016 into JuliaLang:master Jul 4, 2024
7 checks passed
end
AT = (AT !== :_) ? AT : nothing
RT = (RT !== :_) ? RT : nothing
return esc(Expr(:opaque_closure, AT, RT, RT, ex))
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't rt_lb be Union{} instead of RT?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would allow the optimizer to change the return type, but the purpose of this syntax is to guarantee that the optimizer won't change the type on you.

e.g. you need to generate an OpaqueClosure{Tuple{Int,Int},Int} because it will be put into a container - an OpaqueClosure{Tuple{Int,Int},Union{}} would be the wrong thing to generate

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.

3 participants