Safety and Runtime ModelMemory by Example
Blorp by Example

Memory by Example

Blorp gives source values value semantics, while ARC and COW keep ordinary copies efficient.

Value Semantics

Assignment creates another name for the same value, not a mutable reference to be changed through either name.

values.brp
original: List[Int] = [1, 2]
snapshot: List[Int] = original

Arc/cow

ARC and copy-on-write let containers share storage until an update would be observable.

cow.brp
updated: List[Int] = alias.append(3)
-- original is still [1, 2]

Aliases

append through one name returns a new list value; the earlier alias keeps seeing the original list.

alias.brp
a: List[Int] = [1]
b: List[Int] = a
c: List[Int] = b.append(2)

Closure Capture

Closures capture values, not mutable variables by reference, which keeps cross-task captures safe.

capture.brp
pure func make_adder(base: Int) -> pure (Int) -> Int:
    pure func(x): x + base

Example

memory.brp
pure func make_label(prefix: String) -> pure (Int) -> String:
	pure func(n: Int): prefix + n.to_string()


func main(args: List[String]) -> Void:
	original: List[Int] = [1, 2, 3]
	snapshot: List[Int] = original
	updated: List[Int] = snapshot.append(4)

	label = make_label("count: ")
	print(original
			.length()
			.to_string())
	print(updated
			.length()
			.to_string())
	print(label(updated.length()))

Try It

terminal
blorp run memory.brp