I would like to understand a little bit more about the answer to the question implied on the title of this topic of mine, as per the following question from StackOverflow: List of loaded/imported packages in Julia. The answer by Przemislaw Szufel seems the best one for me:
filter((x) -> typeof(eval(x)) <: Module && x ≠ :Main, names(Main,imported=true))
but I do not understand clearly the need for the eval function inside the typeof function in the conditional to the filter function. Could someone explain it from first principles? I have looked up the help for eval to no avail…
names returns a list of symbols, eval(name) “evaluates” the symbol into the object it represents in the current Julia session. typeof(eval(x)) <: Module checks whether or not that object is a module.
@baggepinnen, showall(Base.loaded_modules) returns 174 items, including crazy things like FriBidi_jll, while the @pszufe’s user function loadedModules() returns 16 explicitly loaded packages, as expected.
Base.loaded_modules appears to include all modules that are loaded, even if they are loaded indirectly (not explicitly by the user). This includes jll packages that contain pre-compiled and packaged binaries.
I noticed that, but why does eval(:Base) for instance returns Base (which happens to be of type Module, no longer Symbol)? I was not able to get this crystal clear from eval’s function help, though I do see, via the REPL, it is what it does. I guess I really do not get what eval does…