daii - allocator-friendly closures and raii

Martin Nowak via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Mon Jul 10 07:04:48 PDT 2017


On 06/23/2017 09:02 PM, Boris-Barboris wrote:
> Hi, I wrote a small library, inspired by atilaneves automem. I didn't
> like some things, especially that smart pointers proxied underlying
> types, also I wanted class upcasting.
> 
> https://github.com/Boris-Barboris/daii
> https://code.dlang.org/packages/daii
> 
> What do you think about the delegate\closure syntax?
> 
> https://github.com/Boris-Barboris/daii#delegate
> 
> Any ideas and contributions are appreciated.

Looks interesting, covariance (upcasting) is definitely a feature
requirement for an standard rc library.
The delegates are interesting. A bit brittle, guess we need some
compiler supported lowering to make non-GC allocated delegates cleaner.

You could try sth. along the lines of

delegate!(sum, "(int v) => sum += v")

but that needs a mixin to rebind the lambda's context.

-Martin


More information about the Digitalmars-d-announce mailing list