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

FoundationsValues and Names

Values and Names

Names are immutable by default; var is the explicit rebinding marker.

Inferred Bindings

A name can omit its type when the initializer is enough for the compiler to infer it.

score = 82 -- inferred as Int

label = "passing" -- inferred as String

Explicit Annotations

Use name: Type when the type is part of the contract or makes the example clearer.

score: Int = 82

name: String = "Ada"

Immutable Names

A plain binding cannot be assigned again.

score: Int = 82
-- score = 91  -- rejected

`var` Rebinding

var allows a local name to point at a new value. Collection updates return new values, so scores = scores.append(x) is the core pattern.

func main(args: List[String]) -> Void:
	var scores: List[Int] = []

	scores = scores.append(82)
-- scores.append(82) without a binding does nothing and is rejected by the compiler

Example

scores.brp
func main(args: List[String]) -> Void:
	raw = [82, 91, 77]
	var scores: List[Int] = []

	for score in raw:
		scores = scores.append(score)

	print(scores.length()) -- prints: 3

Try it

terminal
blorp run scores.brp