Re: Lambda cannot access frame of function

2017-11-18 Thread Ali Çehreli via Digitalmars-d-learn
On 11/18/2017 06:22 AM, kerdemdemir wrote: //DMD64 D Compiler 2.072.2 import std.stdio; bool foo(  bool function( double ) controlFoo ) {     return controlFoo(5.0); } void foo2( double val ) {     writeln  ( foo( a => a > val ) ); } void main() {     foo2(20);     writeln("Hello, World!")

Re: Lambda cannot access frame of function

2017-11-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 18 November 2017 at 14:22:19 UTC, kerdemdemir wrote: bool foo( bool function( double ) controlFoo ) Change that `function` to `delegate` and it should work. Function pointers aren't allowed to access other locals, but delegates are.

Re: Lambda cannot access frame of function

2017-11-18 Thread kerdemdemir via Digitalmars-d-learn
On Saturday, 18 November 2017 at 14:30:29 UTC, Adam D. Ruppe wrote: On Saturday, 18 November 2017 at 14:22:19 UTC, kerdemdemir wrote: bool foo( bool function( double ) controlFoo ) Change that `function` to `delegate` and it should work. Function pointers aren't allowed to access other local

Lambda cannot access frame of function

2017-11-18 Thread kerdemdemir via Digitalmars-d-learn
//DMD64 D Compiler 2.072.2 import std.stdio; bool foo( bool function( double ) controlFoo ) { return controlFoo(5.0); } void foo2( double val ) { writeln ( foo( a => a > val ) ); } void main() { foo2(20); writeln("Hello, World!"); } Does not compile and gives this errors: sou