Skip to content

Modules

Each source file is a translation unit in the Bjarne language. Modules are the resolution to sharing symbols and declarations across translation units and modules, while avoiding the issues arising from the archeic header file inclusion system. In Bjanre language, a namepace is a module.

The Keywords:

import, export, namespace, public, private, protected, and final.

Example Code

// parent module.bear

export namespace parent_lib
{
public:
    // some publicly accessible code of parent_lib: enum, struct, interface, class, constants, methods, etc.
protected:
    // some protected code of parent_lib (only accessible from parent_lib's children): enum, struct, interface, class, constants, methods, etc.
private:
    // some privately accessible code of parent_lib: enum, struct, interface, class, constants, methods, etc.
}
// extended module.bear
import parent_lib;

// the final keyword limits other modules from inheriting from the modules with the "final."
export namespace extended_lib final : public parent_lib // derive as is. The parent's privates are inaccessible.
{ 
   // some code: enum, struct, interface, class, constants, methods, etc. 
}

export namespace extended_lib2 : protected parent_lib // turn all parental symbols to protected. The parent's privates are inaccessible.
{
    // some code: enum, struct, interface, class, constants, methods, etc. 
}

export namespace extended_lib3 : private parent_lib // turn all parental symbols to private. The parent's privates are inaccessible.
{
    // some code: enum, struct, interface, class, constants, methods, etc. 
public:
    namespace submodule
    {

    }
}