Direct proxies update

David Bruant bruant.d at gmail.com
Tue Nov 29 10:01:08 PST 2011


Le 29/11/2011 18:40, Tom Van Cutsem a écrit :
> 2011/11/29 David Bruant <bruant.d at gmail.com <mailto:bruant.d at gmail.com>>
>
>     Promises sounds promising, but I'm not sure it will entirely fill
>     the gap. If we're trying to write a function f which works both
>     with local and remote objects, we end up with this:
>     -----
>     function f(o){
>         var a = o.bla;
>         // In the synchronous case, a is the value.
>         // if o is a localFarReferenceMaker, a is a promise.
>
>         // In order to continue for both cases, one would have to do
>     something like:
>         if(isPromise(a)){
>              a.when(function(res){
>                  // do something with the value in res
>              });
>         }
>         else{
>              // do the exact same thing with the value in a
>         }
>     }
>     -----
>
>
> No, it need not be this complicated. Using the strawman Q API
> (<http://wiki.ecmascript.org/doku.php?id=strawman:concurrency>):
>
> function f(o) {
>   var a = o.bla;
>   Q(a).when(function(res) {
>     // do something with the value in res
>   });
> }
>
> Q(x) is a no-op if x is already a promise. If x is a local value, Q(x)
> turns it into a local promise for that value.
> The general rule here is: if your code needs to handle both local and
> remote values, deal with the remote/async case only. The local case
> should be a subset of the remote case.
Oh ok, interesting.
... but does that mean that as soon as we bring concurrency (and
asynchronisity) to ECMAScript, every API manipulating objects (or
potentially any remote value)?

>  (...)
> Also, they are not equivalent: |var f = o.x; f();| would perform an
> HTTP GET "x" under the original semantics, and an HTTP POST "x" given
> your proposal.
... you're right :-s

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111129/bcbf5ba1/attachment.html>


More information about the es-discuss mailing list