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
Document Method
reflection functions
#54432
base: master
Are you sure you want to change the base?
Conversation
Thanks for jumping in to this! I'd love to have a comprehensive reflection API, and I think Julia is mature enough that we can do this without impinging much on future language development. In general,
As this applies to this PR,
|
Thank you for all this feedback! Just to narrow in on one point, would defining |
It would sidestep a bit of it, but we'd still need to decide if |
If people are concerned about committing to
Ah, sorry, I left implicit my assumption that Edit: |
I weakened the docstring for |
The new docstring for |
Okay, I added two functions to public and tightened up the other docstrings. Ready for review! Also, the build is failing because Documenter can't find the docstring for |
@@ -62,6 +62,8 @@ public | |||
isexported, | |||
ispublic, | |||
remove_linenums!, | |||
method_argnames, |
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.
This seems like a weird API to make public: all the declared argument names with #self
prepended.
mutable struct MethodList <: AbstractArray{Method,1} | ||
ms::Array{Method,1} | ||
mt::Core.MethodTable | ||
end | ||
|
||
size(m::MethodList) = size(m.ms) | ||
getindex(m::MethodList, i::Integer) = m.ms[i] | ||
collect(m::MethodList) = m.ms |
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.
This new method eliminates the copy that collect
typically makes. We already have collect(::MethodList)::Vector{Method}
collect(m::MethodList) = m.ms |
@@ -62,6 +62,8 @@ public | |||
isexported, | |||
ispublic, | |||
remove_linenums!, | |||
method_argnames, | |||
signature_type, |
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.
What do other folks think about making signature_type
public?
This PR documents
Method
,MethodList
, and a few functions for retrieving the properties of aMethod
.methods
is partially documented but isn't very useful outside of interactive sessions because nothing it returns is public. The docs are also currently incorrect because they claim thatmethods
returns aMethodTable
, but it actually returns aMethodList
.This partially addresses #20555, but I am intentionally keeping the surface area of this change very small so to judge the interest in this direction. To that end, I do not document
MethodTable
, anything to do with kwargs, nor do I define functions to access any of the more "advanced" properties ofMethod
.This is my first time contributing, so I don't have tooling set up to test building the docs. There is still a lot of clean up to do with regard to adding tests for the new functions, but I want an initial reaction from the maintainers about this PR before burning more time.