Overview

A MUFL library is a collection of functions, variables, types, and modules that offer useful features to other libraries or applications.

Library source files must use the .mm extension.

Here is an example of a MUFL library:

// FILE: coordinates.mm
library coordinates { 
    metadef radial: ... 
    metadef carthesian: ... 
    fn radial_to_cartesian (c:radial) -> cartesian { ... }
    ... 
}

The MUFL compiler loads libraries similarly to how include works in C++. Specify the loads keyword in your code to instruct the compiler to load a library. For example:

// FILE: shapes.mm 
library shapes loads library coordinates { // loads coordinates.mm
    metadef cube: ($position->coordinates::radial, ... ). 
    ... 
}

As described in the section on name visibility, to gain access to the names the library exports, a library must be loaded explicitly. Libraries that are recursively loaded by explicitly-loaded libraries are not visible.

Libraries may contain modules. For example:

// FILE: A.mm
library A { 
    module Hello {
        value = 1. 
    }

    fn print_hello (_) { 
        _print ::A::Hello::value "\n". // prints "1"
    }
    
    print_hello().
}

Prints:

1