Pelago
Modules and imports

Re-exporting with pub import

pub import: importing names and passing them on, to give a package one front door.

pub import imports names and makes them public from the importing module, so a module can gather names from several places and offer them from one.

shapes/circle.pel:

pub fn area(r: int) -> int = 3 * r * r

util.pel:

pub import { area } = .shapes.circle

main.pel:

import { area } = util

fn main() {
    print(area(2))
}

pelago run . prints:

12

main imported area from util, which got it from shapes.circle; main never mentions the inner module. Use this to keep a folder's layout private while exposing a stable set of names.

On this page