On Wednesday, 5 February 2014 at 21:00:32 UTC, Adam D. Ruppe
wrote:
On Wednesday, 5 February 2014 at 20:46:32 UTC, Johannes Pfau
wrote:
However, I wonder if that's really a problem in phobos. I'd
guess most functions accepting slice input don't store a
reference.
We should probably start documenting that. (Or finish 'scope'
as you already said implicitly ;-).
Aye. If the reference never escapes, it doesn't need to be
counted or freed (indeed, it really MUST never be freed, since
whomever passed you that reference may still be using it and is
responsible for freeing it (or passing the buck to the GC))
This. I think simply implementing scope will be much more
important and effective step in optimizing D memory management
model than current roadmap Andrei has posted recently. Simply
because it enables non-breaking enhancements to Phobos that
provide both allocation-free and safe functionality at the same
time and is completely orthogonal to underlying allocation model.