如何查找函数所属的包

sba*_*bac 3 package julia

想象一下,您发现某人编写了一个函数(例如countfrom)。如何找到一个函数所属的包?在这种情况下Iterators

Nil*_*dat 7

您可以使用@which宏:

julia> using StatsBase

julia> @which countmap(rand(1:10, 100))
countmap(x::AbstractArray{T,N} where N; alg) where T in StatsBase at C:\Users\user\.julia\packages\StatsBase\548SN\src\counts.jl:389
Run Code Online (Sandbox Code Playgroud)

请注意,正如文档所述,宏实际上评估特定调用的参数,因为函数可能在不同位置定义了不同的方法。