After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 583482 - Lambdas do not work for delegates with out parameters
Lambdas do not work for delegates with out parameters
Status: RESOLVED DUPLICATE of bug 574403
Product: vala
Classification: Core
Component: general
0.7.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2009-05-21 18:01 UTC by Mike Massonnet
Modified: 2009-05-23 09:44 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Mike Massonnet 2009-05-21 18:01:28 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;
}
Comment 1 Mike Massonnet 2009-05-23 09:44:26 UTC

*** This bug has been marked as a duplicate of 574403 ***