Re: [Vala] [ANNOUNCE] Vala 0.7.6 - Compiler for the GObject type system



Great release!

One question about closures: is it intentional that captured variables
change after the closure? For example:

------------------------------------------------------
delegate void Func ();

void main () {
        int a = 42;
        Func f = () => stdout.printf ("%d\n", a);
        a = 43;
        f ();
}
------------------------------------------------------
Output: 43


This seems to affect currying as well:

------------------------------------------------------
delegate int IntFuncInt (int i);

IntFuncInt curried_add (int a) {
    return b => a + b;
}

void main () {
        int a = 3;
        int b = 4;
        stdout.printf ("%d + %d = %d\n", a, b, curried_add (a)(b));
}
------------------------------------------------------
Output: 3 + 4 = 4


Best regards,

Frederik



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