On Friday 18 September 2009 18:18:33 JM wrote:
> Hi all
> A few days ago I edited the asynchronous stream reading example on the
> vala site to use the new async syntax.
> http://live.gnome.org/Vala/GIOSamples#head-a6170c01121b9fe5825f431de73573b0
>84545741
>
> After the release of vala-0.7.6 I realized that other examples of the
> new syntax use '.begin()' to call the async function.
> I compiled the example with and without the .begin keyword and found NO
> DIFFERENCE in the generated C code. Both ways are working properly.
>
> Is there a case where the difference will be more clear?

Right now I think they're equal, although my view is that it should make a 
difference when calling an async function from a synchronous one. The principle 
of least surprise should be that begin() and end() would be collapsed to one 
synchronous call in that particular case.

Right now async has a related problem though for async methods that return 
values, i.e. the following code:

================
async int func()
{
        return 10;
}

void main()
{
        int i = func();
}
================

leads to the -- somewhat surprising -- error message:

================
mic...@andromeda:/local/pkg/vala/test$ valac --pkg gio-2.0 foo.vala
foo.vala:8.10-8.15: error: invocation of void method not allowed as expression
        int i = func();
                ^^^^^^
================

since internally the invocation is moved to func.begin(), which is (always) a 
void method. This is no problem from async to async as we would be using int i 
= yield func() in that case, however it's quite common to call async() from 
sync(), hence some additional work is required here.

:M:

:M:

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

Reply via email to