Array Slices and Interior Pointers

Dmitry Olshansky dmitry.olsh at gmail.com
Wed Dec 12 00:30:14 PST 2012


12/12/2012 12:59 AM, Alex Rønne Petersen пишет:
[snip]
>>
>> I'd mention that the most of idiomatic D code is agnostic with respect
>> to the origin of slice. The major reason to use slices is to avoid
>> allocations and thus the allocation scheme is not important up to the
>> point of explicit copy.
>>
>> And at that point e.g. Phobos plays it safe and does everything that has
>> to copy or incrementally build via GC. And it gets bashed for it every
>> once in a while. To put simply it's because there is no concept of
>> allocators in idiomatic D code _yet_.
>>
>> And separating slices and allocation mechanism behind them is the key of
>> usability of slices as they stand. If we add stuff that makes them 50%
>> more bulky and helps only a certain scheme of GC memory allocation we
>> are screwed.
>
> Then our current slice design is broken.
>
> int[] arr;
> arr.length = 1024; // guess where this memory comes from?
>
Nice one ;)
Guess this point was destroyed.

-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list