Re: delegates & GC allocations

2014-08-20 Thread Ola Fosheim Gr via Digitalmars-d-learn
On Wednesday, 20 August 2014 at 21:30:41 UTC, Etienne wrote: So, my question inspired a new optimization? :-p A decent optimizing compiler would detect that the function is calling itself and save stack space by using register where possible...

Re: delegates & GC allocations

2014-08-20 Thread Etienne via Digitalmars-d-learn
On 2014-08-20 5:25 PM, Ola Fosheim Gr wrote: Well, I guess simple recursion could be solved easily too by having a wrapper function that puts the frame pointer in a free callee save register... So, my question inspired a new optimization? :-p

Re: delegates & GC allocations

2014-08-20 Thread Ola Fosheim Gr via Digitalmars-d-learn
On Wednesday, 20 August 2014 at 21:19:18 UTC, Ola Fosheim Gr wrote: On Wednesday, 20 August 2014 at 20:48:38 UTC, Chris Nicholson-Sauls wrote: On Wednesday, 20 August 2014 at 15:17:52 UTC, Ola Fosheim Gr wrote: Only if it is recursive. Or if it refers to any state of the parent function. As

Re: delegates & GC allocations

2014-08-20 Thread Ola Fosheim Gr via Digitalmars-d-learn
On Wednesday, 20 August 2014 at 20:48:38 UTC, Chris Nicholson-Sauls wrote: On Wednesday, 20 August 2014 at 15:17:52 UTC, Ola Fosheim Gr wrote: non-static nested functions are effectively delegates as it needs a context pointer to parent stack frame. Only if it is recursive. Or if it refers t

Re: delegates & GC allocations

2014-08-20 Thread Chris Nicholson-Sauls via Digitalmars-d-learn
On Wednesday, 20 August 2014 at 15:17:52 UTC, Ola Fosheim Gr wrote: non-static nested functions are effectively delegates as it needs a context pointer to parent stack frame. Only if it is recursive. Or if it refers to any state of the parent function.

Re: delegates & GC allocations

2014-08-20 Thread hane via Digitalmars-d-learn
On Wednesday, 20 August 2014 at 14:44:39 UTC, Etienne wrote: I've been hearing that delegates get a context pointer which will be allocated on the GC. Is this also true for delegates which stay in scope? e.g. void addThree() { int val; void addOne() { val++;

Re: delegates & GC allocations

2014-08-20 Thread Ola Fosheim Gr via Digitalmars-d-learn
non-static nested functions are effectively delegates as it needs a context pointer to parent stack frame. Only if it is recursive.

Re: delegates & GC allocations

2014-08-20 Thread Dicebot via Digitalmars-d-learn
On Wednesday, 20 August 2014 at 14:54:31 UTC, ketmar via Digitalmars-d-learn wrote: On Wed, 20 Aug 2014 10:44:38 -0400 Etienne via Digitalmars-d-learn wrote: and this is not delegate, this is just nested function. non-static nested functions are effectively delegates as it needs a context

Re: delegates & GC allocations

2014-08-20 Thread ketmar via Digitalmars-d-learn
On Wed, 20 Aug 2014 10:44:38 -0400 Etienne via Digitalmars-d-learn wrote: and this is not delegate, this is just nested function. signature.asc Description: PGP signature

Re: delegates & GC allocations

2014-08-20 Thread ketmar via Digitalmars-d-learn
On Wed, 20 Aug 2014 10:44:38 -0400 Etienne via Digitalmars-d-learn wrote: > Will the above function allocate on the GC? no. signature.asc Description: PGP signature

delegates & GC allocations

2014-08-20 Thread Etienne via Digitalmars-d-learn
I've been hearing that delegates get a context pointer which will be allocated on the GC. Is this also true for delegates which stay in scope? e.g. void addThree() { int val; void addOne() { val++; } addOne(); addOne(); ad