Modules
In Sidef, a module is the declaration of a new namespace:
The default namespace name is main
. Variables from other namespaces can be used inside a module by either importing them, or by specifying their full name which includes the namespace:
Importing an identifier in the current namespace, can be done using the syntax import namespace::identifier_name
:
Modules cannot be instantiated as objects, cannot be modified, and cannot be directly referred to by their name (like ModuleName
) without a member name (like ModuleName::var_name
). Therefore, they are for containing related code that doesn't need to be instantiated like a class.
Last updated