I would like to programmatically get the docstring associated to a function – is that possible?
On a related note, how can we apply reflection and introspection techniques to functions? In Julia functions are first-class, but they don’t seem to behave like standard objects (as least the way one might expect by comparison with other languages). What kind of beast is this?
julia> g = (x) -> 2x
(::#23) (generic function with 1 method)
julia> typeof(g)
##23#24
julia> isa(g, Function)
true
julia> f = Function()
ERROR: MethodError: no constructors have been defined for Function
julia> fieldnames(typeof(g))
0-element Array{Symbol,1}
julia> methods(g)
# 1 method for generic function "(::#23)":
(::##23#24)(x) in Main at REPL[8]:1
julia> methods(Function)
# 1 method for generic function "(::Type)":
(::Type{T})(arg) where T in Base at sysimg.jl:77