isconst

isconst([m::Module], s::Symbol) -> Bool

Determine whether a global is declared const in a given Module. The default Module argument is current_module().

Examples

julia> module MyModule
           const x = 5
           y = 10
       end

julia> isconst(MyModule, :x)
true

julia> isconst(MyModule, :y)
false

julia> isconst(:π)
true

In the above examples,

  • isconst(MyModule, :x) checks if the symbol :x in the module MyModule is declared as a constant. It returns true since x is declared as const in MyModule.
  • isconst(MyModule, :y) checks if the symbol :y in the module MyModule is declared as a constant. It returns false since y is not declared as const in MyModule.
  • isconst(:π) checks if the global symbol is declared as a constant. It returns true since π is a constant in the global scope.

Note: If no module is specified, current_module() is used as the default module.

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: