[Issue 15370] New: Some way to manually allocate the closure for delegates to nested functions.
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Sat Nov 21 00:47:35 PST 2015
    
    
  
https://issues.dlang.org/show_bug.cgi?id=15370
          Issue ID: 15370
           Summary: Some way to manually allocate the closure for
                    delegates to nested functions.
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: joeyemmons at yahoo.com
There has been a strong push to move away from the GC, being able to allocate
closures with out it would be another step in that direction. As far as I can
tell there is no current way to manually allocate a closure. It would be great
if there was a solution that could work with allocators to be able to manually
allocate closures. 
Example:
auto foo(int x)
{
   int bar(){ return x; }
   return &bar; 
   // implicitly allocates a closure with the gc
   // No way to manually allocate it currently 
}
Maybe it could be something as simple as __traits(setClosureAllocator,
Mallocator.instance); to set the allocator for the closure of the current
function. 
Allocators then would need to handle the case of freeing the delegate closure
as well.
--
    
    
More information about the Digitalmars-d-bugs
mailing list