"There can be at most one owner for any piece of data."
This doesn't seem right. For GC data, the GC owns the data,
that is true. But for Ref-counted data, there is more than one
owner, and only when all the owners disown the data can it be
destroyed.
I think there is a disconnect here, you can't say *nobody* owns
the data, and if you say one variable owns the data, which one
is it?
Continuing to read...
-Steve
It is in line with this definition
A variable owns the data it contains if, when the lifetime of
the variable is ended, the data can be destroyed.
and the definiton of the lifetime of a variable
The lifetime of variables is based purely on their lexical
scope and order of declaration. The following rules define a
hierarchy of lifetimes:
A variable's lifetime starts at the point of its declaration, and
ends with the lexical scope it is defined in.
An (rvalue) expression's lifetime is temporary; it lives till the
end of the statement that it appears in.
The lifetime of A is higher than that of B, if A appears in a
higher scope than B, or if both appear in the same scope, but A
comes lexically before B. This matches the order of destruction
of local variables.
The lifetime of a function parameter is higher than that of that
function's local variables, but lower than any variables in
higher scopes.
Because the lifetimes of any two variables are different by this
definition and the definition of ownership links to variable
lifetime, only one variable can own the data.
So if you have multiple ref-counted slices to an array, no one
owns the array until the ref-count goes down to 1. Question
remains, if this is a definition of ownership we want to employ.
There can be at most one owner for any piece of data.