News for hackers. Stuff that matters.
Re:CoffeeScript, a little language that compiles to JavaScri... by statictype on Friday December 25, 2009 @09:23PM (#1015627)
Very nice. How about language-level support for asynchronous operations (like the async monad in F#)

    async update_table:q =>
        r1,err = xhr('http://somewhere?q='+q)
        if err then
            $('error').innerHTML = err
            return.
        r2,err = xhr('http://somewhere-else?q='+r1)

        if err then
            $('error').innerHTML = err
            return.

        $('result').innerHTML = r2
        .
could be the equivalent of something like:

    function update_table(q) {
        var on_error = function(err) { $('error').innerHTML = err; }
        
        doXHR('http://somewhere?q='+q
            ,function(r1){
                doXHR('http://somewhere-else?q='+r1,function(r2){
                    $('result').innerHTML = r2;
                },err));
            },err);
        );
        
    }

There are no comments on this comment yet.