If T[new] is the container for T[], then what is the container for T[U]?
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Sat Apr 25 16:44:18 PDT 2009
Christopher Wright wrote:
> Simple solution: put the array definition in object.d and try
> implementing arrays with reference counting or manual memory management.
>
> I think stored slices break manual memory management, even with a
> dedicated slice type; but they should work just fine with refcounting.
> If you don't want to change the language, object.Array will have to
> implement the logic for slices and for allocated arrays. It's a bit
> ugly, and it makes the Array type larger. Also, Array's reference count
> would need to be accessed by reference.
There are three schemes that are good starting points:
1. As right now :o).
2. Using refcounting. Arrays will be 4 words long (begin, end,
end-of-store, refcount*) and slices will be 3 words long (begin, end,
and owner*)
3. Using manual management. Arrays will be 3 words long (begin, end,
end-of-store) and slices will be 2 words long (begin, end). This is
close to C++/STL. This case is less safe but very efficient.
If we manage to integrate them all... that's quite the holy grail. And I
think it's entirely possible with only a few changes to the language.
Andrei
More information about the Digitalmars-d
mailing list