current_module

current_module() -> Module

Get the dynamically current Module, which is the Module code is currently being read from. In general, this is not the same as the module containing the call to this function.

Examples

In the Julia programming language, the function current_module()

Get the dynamically current Module, which is the Module code is currently being read from. In general, this is not the same as the module containing the call to this function.

julia> module MyModule
           function get_current_module()
               return current_module()
           end
       end
Main.MyModule

julia> MyModule.get_current_module()
Main.MyModule

This example demonstrates how to retrieve the current module using the current_module() function. The get_current_module() function is defined within the MyModule module and returns the current module.

Common mistake example:

julia> function print_current_module()
           println(current_module())
       end
print_current_module (generic function with 1 method)

julia> print_current_module()
Main

In this example, current_module() is called from outside any specific module, so it returns Main as the current module. It's important to note that current_module() does not necessarily return the module containing the call to the function, but rather the module code is currently being read from.

See Also

assert, backtrace, code_llvm, code_lowered, code_native, code_typed, code_warntype, :@which, compilecache, current_module, eval, finalize, finalizer, fullname, function_module, function_name, include_dependency, InterruptException, invoke, isconst, isdefined, isgeneric, methodswith, method_exists, module_name, module_parent, require, subtypes, unsafe_load, workspace, __precompile__,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: