On Tuesday, 27 May 2014 at 23:18:12 UTC, Idan Arye wrote:
Well, it won't work for the example that opened this
thread(converted to use lambdas).
As for limiting the delegate version to ones that use @pure and
@nogc, take another look at my example. The lambdas don't
allocate anything so they're obviously @nogc. As for @pure,
they doesn't have any side effects, and depend only on their
arguments(they don't have arguments, and they are constant
functions) and their scope(which happens to be mutable, but you
could easily make it immutable and nothing will change).
Delegates by default allocate a closure. If they're marked @nogc,
they'd be unable to allocate that closure... I think. The pure
annotation is to stop them from accessing global mutable state.