Re: Comparing function pointers

2015-02-12 Thread Mike Parker via Digitalmars-d-learn
On 2/12/2015 3:40 AM, Freddy wrote: import std.stdio; auto test1(){ void testFunc(){ } return &testFunc; } auto test2(){ uint a; void testFunc(){ a=1; } return &testFunc; } void main(){ writeln(test1()==test1());//true writeln(test2()=

Re: Comparing function pointers

2015-02-11 Thread ketmar via Digitalmars-d-learn
On Wed, 11 Feb 2015 18:40:03 +, Freddy wrote: > > import std.stdio; > > auto test1(){ > void testFunc(){ > } > return &testFunc; > } > > auto test2(){ > uint a; > void testFunc(){ > a=1; > } > return &testFunc; > } > > void main()

Re: Comparing function pointers

2015-02-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 11 February 2015 at 18:40:05 UTC, Freddy wrote: Is the intended behavior? Yes. test2 returns a delegate that closes over a separate copy of the local variable, so the data pointer is different each time. You can get the two pointers with .funcptr and .ptr. You'll find .funcptr