If T[new] is the container for T[], then what is the container for T[U]?
Christopher Wright
dhasenan at gmail.com
Sun Apr 26 08:07:04 PDT 2009
Andrei Alexandrescu wrote:
> 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*)
Well, a slice will be begin, end, owner-ref-count*. The owner could move
about the stack or get passed between classes on the heap or something
like that.
> 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.
Agreed.
More information about the Digitalmars-d
mailing list