-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Define @__FUNCTION__
as an alias to var"#self#"
#58909
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
Referencing the discussion about implementations of this in #6733. |
This should also be added to the docs. I'm surprised this isn't caught by CI. |
Thanks; done |
_function_macro_error() = (@noinline; error("@__FUNCTION__ can only be used within a function")) | ||
|
||
""" | ||
@__FUNCTION__ -> Function |
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.
See https://docs.julialang.org/en/v1.13-dev/manual/documentation/#man-writing-documentation
When included, a return type should be written after the signature, separated by
::
, while a named return value should be separated by->
, with a space on both sides.
Also see PR #57012, PR #57583.
I think simply doing it like this might be the best:
@__FUNCTION__ -> Function | |
@__FUNCTION__ |
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.
I copied the style from the @__MODULE__
one.
If we change it, should @__MODULE__
also be updated to remove the -> Module
?
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.
It looks like it's the same for @__LINE__ -> Int
, @__FILE__ -> String
, and @__DIR__ -> String
.
Seeing those, I'm inclined to keep it as-is. Ok to resolve?
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.
Surely the @__MODULE__
, @__LINE__
, @__FILE__
and @__DIR__
were simply not yet updated for the new style.
Seeing those, I'm inclined to keep it as-is. Ok to resolve?
No? IMO if you don't agree with the style guide, you should make a separate PR to change the style guide.
Just as
@__MODULE__
refers to the enclosing module object, the internal variablevar"#self#"
can be used to refer to the enclosing function object.This PR creates an alias
@__FUNCTION__
for this variable to match the naming conventions of existing reflection macros (@__MODULE__
,@__FILE__
, etc.).Fixes #58908 Fixes #6733