GNOME Bugzilla – Bug 583482
Lambdas do not work for delegates with out parameters
Last modified: 2009-05-23 09:44:26 UTC
When a delegate is taking an out parameter like that one: |public delegate void SampleFunc (int a, out int x); then the lambda will be broken wrt the out parameter. The generated CCode will have within the callback a parameter "gint x" instead of "gint *x". If instead of using a lambda, you use a function everything is fine (as long as you specify the out parameter of course). |void f1 (int a, out int x) { | print ("a %d\n", a); | x = a * 10; |} Here is a sample that uses the same code in the function callback and in the lamdba: public delegate void SampleFunc (int a, out int x); void f1 (int a, out int x) { print ("a %d\n", a); x = a * 10; } void f2 (SampleFunc func, int a) { int x; func (a, out x); print ("x %d\n", x); } static int main (string[] args) { /* Passing a function */ f2 (f1, 5); /* Using a lambda */ f2 ( (a, x) => { print ("lambda a %d\n", a); x = a * 10; }, 5); return 0; }
*** This bug has been marked as a duplicate of 574403 ***