std.allocator needs your help

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Sep 23 18:08:37 PDT 2013


On 9/23/13 5:12 PM, deadalnix wrote:
> On Monday, 23 September 2013 at 17:16:40 UTC, Andrei Alexandrescu wrote:
>> The singleton allocator "it" is instrumental for supporting stateful
>> and stateless allocators with ease. It took me a few iterations to get
>> to that, and I'm very pleased with the results. I think it would be
>> difficult to improve on it without making other parts more difficult.
>>
>
> The allocator can use a singleton internally without using "it". I'm
> unclear what is the problem solved.

Composability. My first design had stateful allocators define regular 
methods and stateless (better said global) allocators define static 
methods. That seemed to work well but then allocators composed with them 
also had to define static or nonstatic methods depending on whether the 
parent allocators had state.

Using a singleton instance for stateless allocators has simplified 
things somewhat - everybody defines regular methods, and if they are 
stateless they define the singleton instance.


Andrei


More information about the Digitalmars-d mailing list