D-

Jonathan M Davis jmdavisProg at gmx.com
Sat Feb 11 16:28:21 PST 2012


On Saturday, February 11, 2012 18:01:05 Nick Sabalausky wrote:
> But not all slices are slices of dynamic arrays.

But all slices are still dynamic arrays, even if they refer to a static array. 
They just have a capacity of 0, so any appending will result in them being 
reallocated. And slicing static arrays is one of those things that you 
generally have to be careful about precisely because they aren't managed by 
the GC and can go out of scope before their slices do.

> Yea, manual memory management is hard and you have to be careful. That's
> true slices or not.

Yes, but in this case, you're dealing with a language feature which is 
_designed_ to be managed by the GC. It's not designed for manual memory 
management at all. It's a completely different situation when you're dealing 
with user-defined types.

> Arrays knowing their own length *is* a notable improvement over C.

Indeed, but that's pretty much the only improvement that D makes to arrays 
which is safe to use without a GC without being _very_, _very_ careful.

- Jonathan M Davis


More information about the Digitalmars-d mailing list