Diff between function and delegate
Mathias Lang via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jun 27 12:59:05 PDT 2016
On Monday, 27 June 2016 at 19:34:06 UTC, "Smoke" Adams wrote:
> I have
>
> alias fnc = void function(Object);
> alias del = void delegate();
>
> Does func avoid the GC? I am passing in this to Object so I
> don't technically need a delegate or a "context". I want to be
> sure that I'm actually gaining something here by doing this.
>
> I read somewhere that delegates only require the GC when they
> use objects outside their scope. Do delegates always use the GC
> or only in certain cases?
Delegate don't GC allocate when:
- You take a pointer to a member function
- The function accept a `scope` delegate and you pass a literal
- You use `scope myDG = (Params) { body... }`
More information about the Digitalmars-d-learn
mailing list