Interesting PRs: bringing type system legitimacy to shared allocators

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Sun Apr 30 14:43:26 PDT 2017


On 04/27/2017 07:35 PM, Stanislav Blinov wrote:
> IAllocator is too high level an interface, it doesn't carry any
> information as to what type of memory it can allocate (so we can only
> assume unshared), and does or does it not use GC (so we can only assume
> GC).

Initially all fresh memory is unshared. Whether or not the user 
subsequently shares it is of no consequence to the allocator. Allocators 
must, however, distinguish between reentrant and non-reentrant calls to 
the allocation primitives.

With regard to whether the memory is collectable or not we need some 
more thinking.

> If we are to devise types with allocators as members instead of type
> arguments, we need the additional information. Better to catch invalid
> assignment at compile time than to chase down how a stack allocator from
> one thread ended up in another.

A pass through the root allocators (Mallocator, GCAllocator etc) 
figuring out what attributes could be meaningfully attached would be 
welcome. The rest would rely on inference.


Thanks,

Andrei



More information about the Digitalmars-d mailing list