Modules

// Module is an extension, which is a combination of between language and implementation.

Using module

To use a module, just with a use keyword.

use math

The above statement will load math module and math identifier will be a local variable. By default, math module return a map that contains static functions and properties.

puts math.abs(-5)    // 5

Alias

Using module with another name, or many module have special name, alias is a great way to deal with them.

use m as "math"
use my_math as "this-is-my-custom-math"

Declared variables of use statement are immutable, so you cannot assign value to them.

You should declare using of modules in top of your code.

Creating module

We have two ways to create a module:

1. By code

Create a new file named my-module.m.aup

And use it

Run with aup

Pass option -m path/to/module to tell compiler finds module.

2. With C++

It is not strange at all, because aup is written in C++ 😄

// todo, we'll provide it soon

Last updated

Was this helpful?