Coming from the object-oriented programming background, I missed the ease of looking up which methods can be applied to an object. I understand the beauty of multiple dispatch but I don’t know of a good way to figure out all the methods that are relevant to me.
Is there any way to:
List all methods that returns a specific type
List all methods that take a specific type in any of the arguments.
Ideally, the type hierarchy is respected so looking for methods that return Integer should return methods that return any type of Integers, as in:
Let’s say I found a wonderful method that takes IOBuffer as an argument. So I need to create an IOBuffer in some way but don’t know how.
The purpose of these convenient functions is to quickly look things up without referring back to documentations. In fact, it would be even nicer if there’s a “search engine” that can quickly find things, not just methods but also doc strings. I know I can use Google but it’s nice to cut all the noise away and focus on Julia and my environment (my version, my installed packages, etc.)
Julia objects are created using their constructor i.e., IOBuffer() creates an IOBuffer so there is no need to look it up since it has the same name as the object itself.
It’s possible to list all methods and check their return type by running the type inference (Base.code_typed) but that’s a bit slow and there’s lot of methods in Julia so it’s not very realistic to use this approach as a quick tool to find methods.
For 2. it’s possible get all methods that match a type signature (e.g. Int in second position (Any, Int, Any)), that’s relatively easy and fast