v5 Modules

Motivation

  • organize code
  • control visibility
  • make linking explicit

Syntax

module math { export fn add(a,b){ return a+b; } }
module main { import math; let x = math.add(1,2); }

Rules

  • export only fn/vars
  • qualified access with .
  • main is last
  • imports must refer to earlier modules

Runtime idea

  • module -> map of exports
  • map stored as global const
  • math.add -> math["add"]
1 / 1
Use arrow keys or click edges to navigate. Press H to toggle help, F for fullscreen.