Early preview: syntax, standard library APIs, and tooling may change.

Program StructureImports and Modules

Imports and Modules

Imports make module boundaries explicit while the prelude keeps common names available.

Prelude

Core types, Option, Result, List, Dict, Set, String, and console helpers are available by default.

items: List[Int] = [1, 2, 3]
print(items.length())

Selective Imports

Import just the functions you want with module: name.

import:
	json: parse_json

Qualified Imports

Use module as Alias for a qualified namespace.

import:
	json as Json


func main(args: List[String]) -> Void:
	parsed = Json.parse_json("{}")

File-As-Module

A .brp file can be imported as a module by path.

import:
    ./scores as Scores

print(Scores.classify(82))

Visibility

private keeps helpers inside their module.

private pure func helper(n: Int) -> Int:
	n + 1

Example

scores.brp + main.brp
import:
	./scores as Scores


func main(args: List[String]) -> Void:
	print(Scores.classify(82)) -- prints: passing

Try it

terminal
blorp run main.brp