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.
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.
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.
func main(args: List[String]) -> Void:
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.
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()) -- prints: 3
print(updated.length()) -- prints: 4
print(label(updated.length())) -- prints: count: 4
Try it
terminal
blorp run memory.brp