I'm trying to use anonymous functions to make code more readable and structured.
But one thing at docs makes me sad:
(https://www.angelcode.com/angelscript/sdk/docs/manual/doc_script_anonfunc.html)
It is not yet possible for anonymous functions to access variables declared in the same scope as the function, i.e. they cannot be used as closures.
Is there any chance that local variables become available to use in lambdas?
For example, this code ten times more compact and easier to understand than others without lambda:
void Initialize()
{
Register reg;
reg.OnValueUpdated += function(const Value ∈ val)
{
ProcessReg(reg);
};
}Converting this example to another using globals makes anonymous functions almost not profitable. Nevermind strange symbol in function arguments, it's just code block visualization issue.