<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 5 February 2014 09:51, Andrei Alexandrescu <span dir="ltr"><<a href="mailto:SeeWebsiteForEmail@erdani.org" target="_blank">SeeWebsiteForEmail@erdani.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Consider we add a library slice type called RCSlice!T. It would have the same primitives as T[] but would use reference counting through and through. When the last reference count is gone, the buffer underlying the slice is freed. The underlying allocator will be the GC allocator.<br>

<br>
Now, what if someone doesn't care about the whole RC thing and aims at convenience? There would be a method .toGC that just detaches the slice and disables the reference counter (e.g. by setting it to uint.max/2 or whatever).<br>

<br>
Then people who want reference counting say<br>
<br>
auto x = fun();<br>
<br>
and those who don't care say:<br>
<br>
auto x = fun().toGC();<br>
<br>
<br>
Destroy.</blockquote><div><br></div><div>This doesn't excite me at all.</div><div>What about all other types of allocations? I don't want to mangle my types. What about closures? What about allocations from phobos? What about allocations from 3rd party libs that I have no control over?</div>
<div>I don't like that it requires additional specification, and special treatment to have it detach to the GC.</div><div>There's nothing transparent about that. Another library solution like RefCounted doesn't address the problem.</div>
<div><br></div><div>Counter question; why approach it this way?</div><div>Is there a reason that it needs to be of one kind or the other?</div></div></div></div>