On Wed, 31 Dec 2014 13:52:02 +0000 "Adam D. Ruppe via Digitalmars-d" <digitalmars-d@puremagic.com> wrote:
> On Wednesday, 31 December 2014 at 13:38:05 UTC, Shachar Shemesh > wrote: > > alias dtype = void delegate(int i); > > void func(T)( T d ) > > > Try writing that: > > void func(scope dtype d) > > instead. Or (scope T d) should do it too if you need it to be > templated. The scope keyword tells the compiler that you promise > not to escape it from that scope, so it is safe to use stack > memory. Should prevent the copying to gc of a delegate. (One of > the few places the scope keyword is actually implemented to do > something!) an it's so well hidden that not many people know about it. being a not very careful reader myself i discovered such `scope` usage while reading some code in another project and was a little puzzled.
signature.asc
Description: PGP signature