Stream: helpdesk (published)

Topic: `methodswith` and unexported names


view this post on Zulip Sundar R (Sep 04 2023 at 12:44):

Does methodswith only return names that have been exported into the Main namespace? Even the methodswith(type, Module) form only returns methods of functions which already exist in the Main namespace.

Concretely: XLSX doesn't export any of its functions, including sheetnames. If I've done using XLSX and have a XLSXFile object x, then methodswith(typeof(x), XLSX) returns nothing (0-element Vector{Method}), even though XLSX.sheetnames accepts XLSXFile objects.

methodswith(typeof(x)) without specifying a module returns methods of functions like close and getindex, functions which already exist in Main but which have methods in XLSX.

Is there a way to get the list of the methods that accept an XLSXFile, whether or not their names exist in Main? (Doing XLSX followed by Alt-M to change the current module doesn't change the above behaviour either, which is what led me to believe methodswith is operating based on the Main namespace specifically, and not whatever the current namespace happens to be.)

view this post on Zulip Sebastian Pfitzner (Sep 04 2023 at 12:49):

yes. imho that's a bug or at the very least warrants an additional all kwarg

view this post on Zulip Sebastian Pfitzner (Sep 04 2023 at 15:12):

also see https://github.com/JuliaLang/julia/issues/33866


Last updated: Oct 02 2023 at 04:34 UTC