no one?
help?> names
names(x::Module; all::Bool = false, imported::Bool = false)
Get an array of the names exported by a Module, excluding deprecated names. If all is true, then the list also includes non-exported names defined in the
module, deprecated names, and compiler-generated names. If imported is true, then names explicitly imported from other modules are also included.
Well, with imported=true
you get not all “names explicitly imported …” as I would normally read the docstring. But at least all imported/used modules are listed - thus you can then call
names(BenchmarkTools; all=false)
to get all names exported from BenchmarkTools
and therefore imported into TESTMODULE
(see also code below).
But what if we have a non-exported identifier explicitly imported?
module M0
f1(x) = x
f2() = "f2 available"
export f1
end
module M1
import ..M0
using ..M0: f2
nms = names(@__MODULE__, all=true, imported=true)
mods = [n for n in nms if getproperty(@__MODULE__, n) isa Module]
imported = vcat([names(getproperty(@__MODULE__, mod), all=false) for mod in mods]...)
allnames = union(nms, imported)
println(f2())
@show nms
@show imported
@show allnames
end
julia>
f2 available
nms = [Symbol("#eval"), Symbol("#include"), :M0, :M1, :eval, :include]
imported = [:M0, :f1, :M1]
allnames = [Symbol("#eval"), Symbol("#include"), :M0, :M1, :eval, :include, :f1]
Any idea how to get f2
listed?
Another question: the names()
docstring doesn’t IMO reflect the behavior of the function. What is the intended behavior then?