Vision document for H1 2017
Jonathan M Davis via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Thu Jan 12 22:11:53 PST 2017
On Friday, January 13, 2017 05:33:07 Chris Wright via Digitalmars-d-announce
wrote:
> On Thu, 12 Jan 2017 20:02:38 -0800, Jonathan M Davis via
>
> Digitalmars-d-announce wrote:
> > I don't see how it possibly could given how dynamic arrays work in D. It
> > would have to have some sort of reference counting mechanism, which
> > would likely be a nightmare with slicing
>
> On that topic, D's arrays would play nicer with both refcounting *and*
> modern garbage collectors if they were structured as base, offset, length
> instead of start, length. You could put metadata just before the start of
> the array, including the reference count.
It's actually really nice as well as performant for D's dynamic arrays to be
the way that they are. Adding any kind of reference count into them would
add overhead as well as not play nicely when you're doing stuff like slicing
pointers or static arrays, which should definitely not be ref-counted. If
you're willing to use the GC, they way that D's dynamic arrays work right
now is fantastic. And even if you're not willing to use the GC, the way they
work is great if you have other code managing their memory appropriately and
just don't use the concatentation or appending operations. Plenty of code
would not want any ref-counting to be going on when passing a dynamic array
around.
Having a ref-counted object that's like an array in addition to D's current
dynamic arrays would be fine and great for some programs, but I sure
wouldn't want to lose what we have now.
- Jonathan M Davis
More information about the Digitalmars-d-announce
mailing list