Re: [Vala] Proposal for an improved delegate/lambda handling



Since it is just syntactic sugar, you are free to pass 2 callbacks as parameters or put 2 "pseudo-lambda" expressions after the method call.

--
Ali

On Sat, Oct 18, 2008 at 11:09 PM, Christian Hergert <christian hergert gmail com> wrote:
What about methods that take 2 callbacks?

-- Christian

2008/10/18 Ali Sabil <ali sabil gmail com>:
> Hi all,
>
> I would like to start a discussion about a small syntactic sugar addition to
> Vala, that would in my opinion slightly improve the situation with
> asynchronous code. The following code sample should be self explanatory
> about my proposal:
>
> delegate bool HttpResponseCallback (string response);
>
> public class HttpClient : Object {
>     public void post_request (string request, HttpResponseCallback cb) {
>         cb ("Hello world");
>     }
> }
>
> // Current State
> var client = new HttpClient ();
> client.post_request("GET ....",  (response) => {
>         debug ("got response %s", response);
>         return true;
>     }
> );
>
>
> // Proposed syntax:
> // Vala would basically use the "pseudo-lambda" _expression_
> // following the method call as a parameter to the method call
> client.post_request("GET ....") (string response) {
>     debug ("got response %s", response);
>     return true;
> }
>
> I am very open to comments and suggestions.
>
> Cheers,
>
> --
> Ali
>
> _______________________________________________
> Vala-list mailing list
> Vala-list gnome org
> http://mail.gnome.org/mailman/listinfo/vala-list
>
>



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