Delegates with stackpointers

bauss jj_1337 at live.dk
Sat Sep 29 08:11:01 UTC 2018


On Saturday, 29 September 2018 at 06:01:50 UTC, Ritchie wrote:
> How does a delegate with a stackpointer work? e.g. in this 
> example:
>
> https://run.dlang.io/is/XviMSl
>
> Does the second call to foo not overwrite the stack of the 
> first call and thereby the data pointed to by bar1? How is that 
> data preserved?

In this case "a" will not live on the stack of "foo".

This can be proved by:

Shows all variables in "sequence: (Because "a" is  not used 
within the delegate.)

https://run.dlang.io/is/mwopBi

Shows only "b" and "c" in sequence:

https://run.dlang.io/is/c0rpO8


More information about the Digitalmars-d-learn mailing list