Suppose I have hold of the concrete type of a normal, named Julia function, F = typeof(f). Is it possible to get back f from F? I assume this should work in principle, since F is a singleton type.
You can go with Core.Compiler.singleton_type function which returns the instance field for a concrete DataType. I think this function is used for the same objective as yours (not only for this objective) in Core.Compiler during compilation. This is probably considered "more internal" than directly accessing instance field.
julia> Core.Compiler.singleton_type(typeof(sum))
sum (generic function with 13 methods)
I would use F.instance, but maybe there is some better solution (as this one is using the internals).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With