-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Make var"#self#"
also work for callable structs
#58913
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
I assume this doesn't propose I guess any #-containing names should be compiler internal - if we want normal user code to be able to refer to them we should probably call them something else. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM
Yeah this was not meant to be a public API but I guess this is harmless. |
Co-authored-by: Jeff Bezanson <jeff.bezanson@gmail.com>
I have a thought on how to make this a little cleaner. Can we use This might seem equivalent in the current implementation, but in JuliaLowering.jl the internal names like Also we have precedent for this kind of thing in the way that things like Using |
(Sounds like a fine idea to me)
Just wondering, would introducing this split be adding unnecessary complexity? Because of things like: julia> struct Foo end
julia> (::typeof(sin))(::Foo) = var"#self#";
julia> sin(Foo())
sin (generic function with 15 methods) Idk I guess I wonder if it’s simpler to normalize to |
Perhaps you could have
and so on. |
What is complex about this case? Actually I'm not sure there really is a split; it just returns the name of the first argument in all cases. |
We already have |
Regarding returning the first argument in all cases, are there potential issues with |
Sounds good to me. I'll give it a go |
The
var"#self#"
symbol refers to the enclosing innermost function. This PR defines it for callable structs to help make usage symmetric. This was first mentioned in #6733 (comment) (@c42f).This is independent of #58909, but would help make a potential
@__FUNCTION__
macro more general.In the current code,
var"#self#"
does not work with callable structs:If combined with #58909 we can update the tests to use
@__FUNCTION__
rather thanvar"#symbol#"
.