Digging a little deeper, I have some more confusion.  This makes the
for-loop and the foreach-loop behave differently.  What do you think of:

// capturing the for variable should capture a copy if the variable is
// local to the for loop

public delegate void Thunk();

int main() {
        Thunk thunk = () => {};
        for (int i = 0; i < 1; i++) {
                thunk = () => {
                        stderr.printf ("%d = 0, right?\n", i);
                };
        }
        thunk ();
        int[] indices = { 0 };
        foreach (var i in indices) {
                thunk = () => {
                        stderr.printf ("%d = 0, right?\n", i);
                };
        }
        thunk ();
        return 0;
}




Confusingly,

Vivien
_______________________________________________
vala-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to