www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to call one anonymous function from another

reply "Adil" <simplyadilb gmail.com> writes:
I have an SCGI server that needs to run a user defined request
handler, but i can't get it to run

void SCGIServer(ushort port, void function(const Request, Socket)
handler)
        {
            GenericServer(port, function void(const byte[] request,
Socket connection){
                auto r = getRequest(cast(char[]) request);
                writeln(r); //Ok, prints out the key-vals
//            handler(r, connection); // Compile time ERROR :
            });
        }

The error is :

src/scgi/SCGIServer.d(20): Error: function
scgi.SCGIServer.SCGIServer.__funcliteral2 cannot access frame of
function scgi.SCGIServer.SCGIServer
Sep 02 2012
parent "Adil" <simplyadilb gmail.com> writes:
Answer: Read delegates! *slap on forehead*

On Sunday, 2 September 2012 at 14:46:13 UTC, Adil wrote:
 I have an SCGI server that needs to run a user defined request
 handler, but i can't get it to run

 void SCGIServer(ushort port, void function(const Request, 
 Socket)
 handler)
        {
            GenericServer(port, function void(const byte[] 
 request,
 Socket connection){
                auto r = getRequest(cast(char[]) request);
                writeln(r); //Ok, prints out the key-vals
 //            handler(r, connection); // Compile time ERROR :
            });
        }

 The error is :

 src/scgi/SCGIServer.d(20): Error: function
 scgi.SCGIServer.SCGIServer.__funcliteral2 cannot access frame of
 function scgi.SCGIServer.SCGIServer
Sep 02 2012