Closed jpellegrini closed 7 months ago
I have applied this PR, but have not retained the :internal
, :imported
and :exported
key parameters. The main reason is that the result is not always accurate. For instance, if a symbol is imported but redefined in a module, it will not be found by the apropos
command. This could be avoided since it is possible to know if a symbol is an alias or a locally defined variable. However, it depends heavily on the current implementation of global variables which will probably change in the future.
However, the behavior of apropos
depends on the queried module: if the given module is the current one, it returns the symbols defined or imported by the current module. Otherwise, it returns the exported symbols by this module.
Hence, apropos
tries to return the symbols that can be used from the given module.
There is a place for another function, which tries to find information in modules in an easier way than exploiting directly module introspection functions, but having a separate function for that seems, imo, preferable.
Otherwise, I kept the functions apropos/alist
and apropos/pp
which is a really good idea.
Hi @egallesio ! I hope I'm not sending too many PRs... :) I had an idea -- the
apropos
procedure could be enhanced. I have implemented some additional features:#t
is passed, then it is searched in all modulesapropos/alist
returns an association list that has the symbols categorized by module; andapropos/pp
returns#void
, but prints a categorized list of modules on the current output port.:internal
means "look for symbols defined in the module":imported
means "look for symbols in the module imports":exported
means "look for symbols exported by the module" The default is to only bring exported symbols.I couldn't actually use
:key
and:rest
, so I implemented this by hand.And I also included some tests.
Here's the documentation:
These procedures return the symbols whose print name contains the characters of
obj
as a substring, in the specified modules. The givenobj
can be a string or symbol, and each module argument can be a symbol, a string, or the module itself.module
is provided, the current module is used.#t
argument is given for amodule
, then all matching symbols from all modules will be searched.The keyword arguments are boolean:
:internal
is true, include the list of symbols defined inside the module:imported
is true, include the list of symbols imported by the module:exported
is true, include the symbols exported by the moduleThe default is to list only the exported symbols.
The three variants of |apropos| are:
apropos
returns a flat list of symbols, and no information abotu the modules where they are defined.apropos/alist
returns an association list where the key is a module name (as a symbol) and the data is a list of matched symbols which can be accessed from the given module.apropos/pp
does not have a return value, but prints the symbols on the screen, categorized by module.Note that using
#t
will bring the same symbols in several different modules, since modules (as opposed to libraries) inherit all bindings in thestklos
module.Examples:
Also: