Re: [Vala] Newbie help needed for Vala delegates/lambda expressions



On 08/31/17 05:46, Nor Jaidi Tuah wrote:

int c1 = f_add(a)(b);
int c2 = f_add2(a, b);  //Problem here


try f_add2(a,b)()


Nice day
Nor Jaidi Tuah


Hi Nor/Al/others,

Thanks for responding to my query.

I could make my code work by calling it with f_add2()(a, b). This leads 
me to think generally as under.

If a declare a delegate like this :

delegate return_type _DG_xyz(argset_1);

and then define a function which will return using above lambda

_DG_xyz fx(argset_2)
{
        //lambda-expression
}

Then argset_1 and argset_2 are independent of each other. argset_1 
corresponds to the arguments for the lambda-expression, not for the 
client function fx. fx can use any argument list of its own and do 
anything as long as it returns [a function pointer to] a lambda that 
uses argset_1

Am I right about my conclusion ?

Manish Jain


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]