On Tuesday, 3 March 2015 at 08:04:25 UTC, Manu wrote:
My immediate impression on this problem:

s.array[0] is being passed to foo from main. s does not belong to main
(is global), and main does not hold have a reference to s.array.
Shouldn't main just need to inc/dec array around the call to foo when
passing un-owned references down the call tree.
It seems to me that there always needs to be a reference _somewhere_ on the stack for anything being passed down the call tree (unless the function is pure). Seems simplest to capture a stack ref at the top
level, then as it's received as arguments to each callee, it's
effectively owned by those functions and they don't need to worry
anymore.

So, passing global x to some function; inc/dec x around the function call that it's passed to...? Then the stack has its own reference, and
the global reference can go away safely.

This is my position too.

There is another problem being discussed now, however, having to do with references to non-rc'd subcomponents of an Rc'd type.

Reply via email to