std.allocator ready for some abuse
Maxim Fomin
maxim at maxim-fomin.ru
Fri Oct 25 01:20:17 PDT 2013
On Friday, 25 October 2013 at 08:13:21 UTC, Namespace wrote:
>>> Are you saying that this code:
>>> ----
>>> with (setAllocator!Mallocator) {
>>> int[] arr;
>>> arr ~= 42; [1]
>>> }
>>> ----
>>> use the mallocator for [1]? So no GC memory is needed?
>>>
>>> Another examaple:
>>> ----
>>> with (setAllocator!ScopeAllocator) {
>>> int[] arr;
>>> arr ~= 42; [1]
>>> }
>>> ----
>>> Did [1] use ScopeAllocator for memory allocation? And is the
>>> memory of arr automatically collected at the end of the scope
>>> with ScopeAllocator?
>>
>> This is impossible because with() has already another meaning.
>> However nothing stops from inventing another name for this.
>> Compiler can insert calls to druntime as well to other context
>> dependent functions. After allocator design is defined we can
>> move on to step 2, implementing this idea.
>
> You mena something like this?
> ----
> use(Mallocator) {
> int[] arr;
> arr ~= 42;
> }
> ----
> Or did I understand you wrong?
It depends on how Mallocator is related to integer array (which
again boils down to allocator design). If it is appropriate, then
yes.
>
> Whats about the virtual property idea, that every array has
> internal an allocator? Wouldn't it be easier to implement such
> a thing?
Please provide example.
More information about the Digitalmars-d
mailing list