Something went wrong. Try again.
An experiment in static, refcounted, procedural language with ownership
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344fn extern "c" printf(fmt: ptr[u8], ..) i32type Box(value: int)type Ref(box: &Box)type Mut(box: &mut Box)type Bag(a: Box, b: Box)fn main() unit = { let mut box = Box(1) box.print() // Coerced to &Box box.set(42) // Coerced to &mut Box box.print() // box.value == 42 let r = Ref(&box) print(r.box) let mut bag = Bag(Box(2), Box(3)).copy().copy() let ref-a = &mut bag.a let ref-b = &bag.b let ref-a = ref-a let ref-b = ref-b let ref-bag = &bag let a = &ref-bag.a let b = &ref-bag.b print(ref-a) print(ref-b) let mut box = Box(1) let mut rmut = Mut(&mut box) let m = &mut rmut.box rmut.box.value = 2}fn print(box: &Box) unit = { unsafe printf("Box(%d)\n".ptr, box.value)}fn set(box: &mut Box, value: int) unit = box.value = valuefn copy(bag: Bag) Bag = Bag(bag.a, bag.b)