Avoid GC with closures
ZombineDev via Digitalmars-d
digitalmars-d at puremagic.com
Sun May 29 04:53:01 PDT 2016
On Sunday, 29 May 2016 at 11:16:57 UTC, Dicebot wrote:
> On 05/28/2016 09:58 PM, Iakh wrote:
>> Yeah. It doesn't capture any context. But once it does it
>> would be an error.
>
> Custom allocators are not very suitable for things like
> closures because of undefined lifetime. Even if it was allowed
> to replace allocator, you would be limited to either GC or RC
> based one anyway to keep things @safe.
Maybe an interface for a ref counting allocator (that leverages
Andrei's idea to use AffixAllocator's interface for storing RC
metadata) can be used, provided that the interface is in druntime
and the compiler knows how to use it.
BTW, AffixAllocator's interface abstracts whether the metadata is
stored next to the allocation or in a separate area, but the
current design needs to be fixed w.r.t to shared-ness, because it
breaks the type system:
http://forum.dlang.org/post/bscksxwxuvzefymbiemg@forum.dlang.org
More information about the Digitalmars-d
mailing list