Defer in D
Nick Treleaven via Digitalmars-d
digitalmars-d at puremagic.com
Sun Mar 20 07:11:11 PDT 2016
On Saturday, 19 March 2016 at 23:16:40 UTC, Xinok wrote:
>
> I took a quick look through Phobos but didn't see anything
> similar so I wrote this as a proof of concept and to elicit
> discussion. This also works should the function throw rather
> than return gracefully.
>
> http://dpaste.dzfl.pl/23c665bdae9e
Nice! This is more flexible than Go's defer as you can have more
than one stack of them.
I don't quite get this:
> defer((int i) => writeln(i), i);
If it was defer(() => writeln(i)), would that do the same?
(Dpaste won't seem to let me edit your example on my tablet).
More information about the Digitalmars-d
mailing list