On Sunday, 28 May 2017 at 17:34:30 UTC, Nerve wrote:

--- refcounted ---

The allocation method used by refcounted can be overloaded...

1. Then the deallocation has to also be overloaded.
2. This introduces tight coupling between a type and its allocator, preventing the programmer from reusing the same types with different allocators, which is crucial when we're talking about manual memory management.

--- unique ---

Keyword "unique" allocates an object on the stack. It is only accessible to the given scope, child scopes, or functions it is explicitly passed to. Therefore, it does not use an allocator.

We already have that via DIP1000 and "scope".

I may be missing some things, but I've left out some exhaustive details since I'm sure many of you are already experienced in the subject and aren't looking for complete documentation in a proposal like this.

Feel free to level criticism, and let me know if I should submit a DIP.

IMHO, since we're theorizing here, the more feasible direction to take would be to allow expressing ownership, and explicitly qualifying types and variables as nogc. The rest should be left up to programmer, as only they are responsible for imposing concrete requirements on allocation/deallocation.

Reply via email to