fn 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})") }