gorillascript icon indicating copy to clipboard operation
gorillascript copied to clipboard

byref parameters and invocation

Open ckknight opened this issue 12 years ago • 1 comments

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

ckknight avatar May 24 '13 03:05 ckknight

byref would not be compatible with spread parameters or immutable locals.

ckknight avatar May 24 '13 03:05 ckknight