Docs
chromia.com

Abstract module

On this page

Abstract modules and functions allow you to design reusable code components that you can adapt to specific needs within your client modules.

Definition

  • Abstract Modules: Lay the foundation for customization by declaring a module as abstract:

    Rell
    abstract module;
  • Abstract Functions: Outline a function's signature without implementing its body:

    Rell
    abstract function customize(x: integer): text;

    It is also possible to supply an implementation that will serve as a default implementation:

    Rell
    abstract function customize(x: integer): text = "Default";

Override for customization

  • Import the Abstract Module: Bring the abstract module into your client module to access its components:

    Rell
    import lib;
  • Override Abstract Functions: Provide concrete implementations tailored to your specific requirements:

    Rell
    override function lib.customize(x: integer): text {
        // Your customized implementation here
    }

Example

abstract_vehicle.rellRell
abstract module;

abstract function is_4wd(): boolean = false;
abstract function has_four_doors(): boolean;
sportscar.rellRell
module;

import abstract_vehicle.*;

override function has_four_doors() = false;
main.rellRell
module;

import sportscar;

// Returns (is_4wd = true, has_four_doors = false)
query sports_car_details() = (
    is_4wd = sportscar.is_4wd(),
    has_four_doors = sportscar.has_four_doors()
    );