Ownership Annotations

Thanks for updating your proposal!

I'm concerned that this naming leads to some confusion surrounding the difference between the ownership parameter convention and a borrowed variable (in the future).

The ownership convention applies to the callee-side argument handling. If the argument also happens to be a move-only type, then that forces the caller to either move the argument (owned) or borrow the argument (guaranteed), and that can be implicit.

However, the current implementation of the owned/guaranteed neither moves nor borrows the argument, and I don't expect that to change for non-move-only types. So, there needs to be an explicit way do this:

func consumesArg(x: Any) {
  MyClass.staticProperty = x
}

func usesArg(y: Any) -> Any {
  yield y
}

var z: Any

consumesArg(move(z))

usesArg(borrow(z))

So, what you're calling a "borrowed" argument convention is required for borrowing an argument, but does not imply that the argument is borrowed. People need to understand the difference, so we shouldn't use the same name for both concepts.

I also do not think we should surface the "guaranteed" name to the language, that's even more confusing. We should simply have an owned/unowned convention. Since unowned is typically the default, you would almost never use it.

1 Like