-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
InteractiveUtils: Support callable objects as functions in introspection macros #58905
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
base: master
Are you sure you want to change the base?
Conversation
This allows you to call, e.g., `code_typed((Foo, Int, Int))` to query the code for `(::Foo)(::Int, ::Int)`
… `code_warntype`
This allows you to call, e.g., `code_typed((Foo, Int, Int))` to query the code for `(::Foo)(::Int, ::Int)`
… `code_warntype`
Has this impacted julia> const oc = Base.Experimental.@opaque Tuple{Int,Int}->Int (x,y)->(x+y)
(::Int64, ::Int64)->◌::Int64
julia> @code_typed oc(1,2)
OpaqueClosure(...) @ Core none:0 => Any |
Oh, I think we had a branch on |
Perhaps we can have that branch for |
Yeah, that's why I ended up adding I wonder if some equivalent should be moved into |
The tricky bit with opaque closures is that because every "method" can't be distinguished by their type alone, we need to provide the values to reflection functions (whereas at least for callables, we still use types) To support that with the current implementation, we can use the 2-argument form for It seems cleaner to use the |
Isn't that already an issue with switching to the 1-arg form from the 2-arg form? |
That's exactly why I only generate the 1-arg form conditionally on a non-default parameter being set. We could have a parameter that indicates whether or not to dispatch on |
Follow-up to the follow-up #57911, building on the changes to introspection functions to support signature tuples being provided as a single argument.
This enables support for calls of the form
by providing an extra
use_signature_tuple::Bool = false
parameter ingen_call_with_extracted_types
. Setting this parameter to true changes the code generation from$fcn(f, Tuple{argtypes...})
to$fcn(Tuple{f, argtypes...})
(where$fcn
can be e.g.code_typed
,code_llvm
etc).