www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - function cannot access frame

cannot access frame of function

I declared a helper function outside a lambda that is passed to C.

The semantics are the same inside of the function as they are 
outside as far as code goes.

How can I declare a function that essentially works inside the 
lambda also without having to do any real rewriting?

e.g., if I could use a define

#define foo(a,b) a + b

would work great, that is all I really need, templates have the 
same issue as functions though.

To make it work I used a mixin template, but that seems a bit 
obtuse ;/


template put()
     int foo(a,b) { return a + b; }

mixin put;

then I mixin it inside the lambda also. That way I have both 
contexts covered, not bad but...
Aug 20 2017