`borrow` and `take` parameter ownership modifiers

I think take x should produce a temporary move-only value.

For instance, a take x expression could produce a @moveonly X, where @moveonly is a type modifier preventing X–which is copiable–from being implicitly copied. The @moveonly modifier disappears when assigned to a variable, and it also disappears once passed to another function. It's simply a flag attached to the return value that would prevent the compiler from making a copy before the value is passed somewhere else, as if the returned X was, for a moment, a move-only type.

This way the expectation that take x will prevent copying is fulfilled.

(A precedent would be X! which is in reality type X? with a special behavior attached to it, but where the behavior isn't otherwise propagated with the type.)

1 Like