Something went wrong. Try again.
An experiment in static, refcounted, procedural language with ownership
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152fn main() unit = { println("Reference semantics:") ref-type() println() println("Value semantics (extern):") ext-type()}type Ref(field: int)fn ref-type() unit = { let mut r = Ref(1) print(&r) // should be 1 r.field = 2 print(&r) // should be 2 r.mutate() print(&r) // should be 3}fn mutate(r: &mut Ref) unit = { r.field = 3}fn print(r: &Ref) unit = { println("Ref(field: {r.field})")}type Ext extern(field: int)fn ext-type() unit = { let mut ext = Ext(1) print(ext) // should be 1 ext.field = 2 print(ext) // should be 2 ext.mutate() print(ext) // should still be 2}fn mutate(mut ext: Ext) unit = { ext.field = 3}fn print(ext: Ext) unit = { println("Ext(field: {ext.field})")}