gorillascript
gorillascript copied to clipboard
byref parameters and invocation
I'm proposing adding a new syntax to parameter idents and to idents within an invocation call.
It would look like the following:
let f(byref mutable x)
x += 1
let mutable value = 0
f(byref value)
assert value == 1
let obj = { x: 0 }
f(byref obj.x)
assert obj.x == 1
It would be functionally equivalent to the following:
let f(mutable x)
x.$ += 1
let mutable value = 0
f(_tmp := {$:value})
value := _tmp.$
assert value == 1
let obj = { x: 0 }
f(_tmp := {$:obj.x})
obj.x := _tmp.$
assert obj.x == 1
byref would not be compatible with spread parameters or immutable locals.