@Arag, I don't know why I'm arguing for RC other than I thought it might be 
simpler. Re-reading the existing specification 2 on owned ref it doesn't look 
that hard, so I withdraw my argument for RC and just want to see owned ref 
work. In re-reading, I seem to see that there always must be an owned ref that 
actually does the destruction at the end of its scope and to which the 
"unowned" ref's refer.

That works fine for the envisioned use case of a single scope which creates an 
unowned ref has various "unowned" ref's assigned to it including using those to 
pass as parameters to proc's that return back to the owning scope. What isn't 
in the document is the consideration for cases where this common model may not 
be used, as in passing a ref to a closure or another thread:

  1. For closures, I think I saw you mention somewhere that a closure ref would 
have to be owned and I see that there would need to be a means to transfer 
ownership to the environment copy of the variable.
  2. For calling thread proc's or any proc that needs to destroy the ref 
itself, it looks like as long as we can transfer/"move" the ownership to a 
parameter then it also works
  3. In the case of anything such as a proc that needs to transfer ownership to 
the returned value, then the "result" value should never be destroyed as 
responsibility for destruction is passed out to the scope of their caller; thus 
all returned ref's must be owned ref's. I think you may have said that 
somewhere, too.



Sorry about the extensive aside, but I just had to be sure. Let's just make it 
work.

So, given that owned ref works as expected, what about my previous suggestion 
to use Nim's strong typing and overload abilities to eliminate the problem of 
not handling fields that are pointers to the same thing by extending the 
"hooks" to apply to every kind of type recursively and not just objects? That 
has nothing to do with owned ref or most of the memory management model but 
only to do with that one limitation. If you don't ind that idea, I'll write 
something more extensive up and post it whereever you would like?

Reply via email to