Skip to content

reflection: refine and accurately define the options for names #54659

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

Merged
merged 1 commit into from
Jun 21, 2024

Conversation

aviatesk
Copy link
Member

@aviatesk aviatesk commented Jun 3, 2024

This commit refines the keyword arguments that names can accept, allowing for more specific exclusions, such as excluding deprecated names or implicitly using-ed names.
For the new behavior of names, please refer to the following docstring:

names(x::Module; non_public::Bool=false, imported::Bool=false,
                 usings_explicit::Bool=false, usings_implicit::Bool=false,
                 generated::Bool=false, deprecated::Bool=false,
                 [usings::Bool=false], [all::Bool=false]) -> Vector{Symbol}

Return a vector of the sorted names of module x.

By default, only public names defined within x are returned.

By specifying the following keyword arguments, additional names can be included:

  • non_public=true: includes names defined within x that are not public.
  • imported=true: includes names explicitly imported from other modules via import statements.
  • usings_explicit=true: includes names explicitly imported from other modules via using statements.
  • usings_implicit=true: includes names implicitly imported from other modules via using statements
    (i.e., names exported by modules that x has using-ed).
  • generated=true: includes names generated by the compiler frontend (specifically those starting with #).
  • deprecated=true: includes deprecated names.

Note that the previously existing options (all and usings) are retained as alias arguments, ensuring that the previous behavior of names is preserved.

Additionally, the following keyword arguments can be used as aliases to conveniently specify these options:

  • usings::Bool=true: a shortcut to set both usings_explicit and usings_implicit to true.
  • all::Bool=true: a shortcut to set non_public, generated, and deprecated to true.

By utilizing these newly and accurately defined options, the implementation of downstream applications like REPL completions can be simplified.

@aviatesk aviatesk force-pushed the avi/refactor-names branch 3 times, most recently from 1275a10 to 91f75bf Compare June 4, 2024 03:44
@nsajko nsajko added the modules label Jun 10, 2024
This commit refines the keyword arguments that `names` can accept,
allowing for more specific exclusions, such as excluding deprecated
names or implicitly `using`-ed names.
For the new behavior of `names`, please refer to the following docstring:

>     names(x::Module; non_public::Bool=false, imported::Bool=false,
>                      usings_explicit::Bool=false, usings_implicit::Bool=false,
>                      generated::Bool=false, deprecated::Bool=false,
>                      [usings::Bool=false], [all::Bool=false]) -> Vector{Symbol}
>
> Return a vector of the sorted names of module `x`.
>
> By default, only public names defined within `x` are returned.
>
> By specifying the following keyword arguments, additional names can be included:
> - `non_public=true`: includes names defined within `x` that are not public.
> - `imported=true`: includes names explicitly imported from other modules via `import` statements.
> - `usings_explicit=true`: includes names explicitly imported from other modules via `using` statements.
> - `usings_implicit=true`: includes names implicitly imported from other modules via `using` statements
  (i.e., names exported by modules that `x` has `using`-ed).
> - `generated=true`: includes names generated by the compiler frontend (specifically those starting with `#`).
> - `deprecated=true`: includes deprecated names.

Note that the previously existing options (`all` and `usings`) are
retained as alias arguments, ensuring that the previous behavior of
`names` is preserved.
> Additionally, the following keyword arguments can be used as aliases to conveniently specify these options:
> - `usings::Bool=true`: a shortcut to set both `usings_explicit` and `usings_implicit` to `true`.
> - `all::Bool=true`: a shortcut to set `non_public`, `generated`, and `deprecated` to `true`.

By utilizing these newly and accurately defined options, the
implementation of downstream applications like REPL completions can be
simplified.
@aviatesk aviatesk force-pushed the avi/refactor-names branch from 91f75bf to 3620254 Compare June 21, 2024 04:59
@aviatesk aviatesk merged commit 3849c9d into master Jun 21, 2024
@aviatesk aviatesk deleted the avi/refactor-names branch June 21, 2024 16:54
@ronisbr
Copy link
Member

ronisbr commented Jun 25, 2024

Hi @aviatesk !

I think this commit breaks Reexport.jl and therefore all the packages that rely on it. For some reason, names now does not show the symbols reexported by @reexport as I mentioned in #54885

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants