Problem
Ada's parameter modes (in, out, in out) make mutation intent explicit at the call site and function signature. Gengo parameters are effectively pass-by-value (closures capture by cell; structs are passed by reference to the heap object but the binding is not re-assignable from the caller's side).
There is currently no way to signal at the signature or call site that a function mutates or initialises its argument.
Proposed direction
func swap(a in out int, b in out int) {
a, b = b, a
}
swap(x, y) // caller can see mutation is possible
in (default, may be omitted): read-only parameter; compiler rejects assignment to it inside the body
out: write-only; must be assigned before use inside the body; initialised on return
in out: readable and writable; changes are reflected at the call site
Notes
in is already the effective default (const params). Making it explicit is low cost.
out and in out require pass-by-reference semantics, which the current calling convention does not support for scalars. This may require VM changes.
- Lower priority than exhaustiveness checking and typed errors. Needs design discussion.
Problem
Ada's parameter modes (
in,out,in out) make mutation intent explicit at the call site and function signature. Gengo parameters are effectively pass-by-value (closures capture by cell; structs are passed by reference to the heap object but the binding is not re-assignable from the caller's side).There is currently no way to signal at the signature or call site that a function mutates or initialises its argument.
Proposed direction
in(default, may be omitted): read-only parameter; compiler rejects assignment to it inside the bodyout: write-only; must be assigned before use inside the body; initialised on returnin out: readable and writable; changes are reflected at the call siteNotes
inis already the effective default (const params). Making it explicit is low cost.outandin outrequire pass-by-reference semantics, which the current calling convention does not support for scalars. This may require VM changes.