FoundationsValues and Names
Blorp by Example

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.

names.brp
score = 82
label = "passing"

Explicit Annotations

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

types.brp
score: Int = 82
name: String = "Ada"

Immutable Names

A plain binding cannot be assigned again.

immutable.brp
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.

rebind.brp
var scores: List[Int] = []
scores = scores.append(82)

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()
			.to_string())

Try It

terminal
blorp run scores.brp