ownref ------ Via each code path in a function, one or more "ownref" references may be acquired, either from the start of the function, or during it's execution. Each acquired "ownref" must, for each possible code path, either be passed into another function, returned or stored inside another data type (where an "ownref" is accepted). A data structure that contains an "ownref" is considered to be owned by that data structure. When an "ownref" is de-acquired, it must be guaranteed that nobody has "ref" references to it ("ownref" references are forbidden by the rules above). ** TODO solve this... or is it solved by the "ref" rules below? ** ref --- (including "ownref" referenced from data structures, when the data structure is not owned) When a function or structure is passed/assigned a "ref" reference, the caller/assigner promises that the reference must be valid throughout the runtime of the function or the lifetime of the data structure. For function calls, this means that it is sufficient that the "ref" is valid at function entry, and that the "ref" is not "aliased" or "threaded". - But sometimes it might be nice to be able to move pointers around, if the lifetime is still preserved. Does this require a new keyword? For data structures, the "ref" must: 1. be valid at least throughout the lifetime of the structure, 2. be cleared before the end its lifetime, or 3. TODO more? We probably need the same rules about "aliased" and "threaded" as for "ownref". ownref(X) ----------- This overrides the "owner" of the reference. X could reference: - some data structure (e.g. another parameter in a function, or a struct field inside it) - a "lifetime parameter placeholder" (i.e. to indicate that two variables have the same lifetime) --> how to define those? --> or skip this, and go with the solution below. alternative solution: - some kind of conditions/pre-conditions/post-conditions?