[Vala] Coroutines (was: [ANNOUNCE] Vala 0.5.1 - Compiler for the GObject type system)



On Tue, 04 Nov 2008 00:16:33 -0800, Jürg Billeter wrote:

void foo () yields {
        message ("hello");
        yield;
        message ("world");
}

void main () {
        foo.begin ();
        message ("vala");
        
        var loop = new MainLoop (null, false);
        loop.run ();
}

This will print the messages in the order "hello" "vala" "world".
The yield statement in the method foo() schedules the rest of the method
to be run in an idle handler. The invocation of foo() in main using
`begin' lets the method return on the first yield instead of waiting for
it to finish.

This doesen't compile for me:

coroutine.c: In function 'foo':
coroutine.c:26: error: 'data' undeclared (first use in this function)
coroutine.c:26: error: (Each undeclared identifier is reported only once
coroutine.c:26: error: for each function it appears in.)
coroutine.c:28: warning: 'return' with a value, in function returning void
coroutine.c:29: error: case label not within a switch statement
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)


Has the (experimental) coroutine syntax changed since then? Or is it
broken at the moment?


Thanks and regards,

Frederik



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