[e-lang] Bang Tutorial redux -- javascript promises
Tyler Close
tyler.close at gmail.com
Thu Feb 5 08:38:18 CST 2009
On Thu, Feb 5, 2009 at 2:11 AM, Toby Murray <toby.murray at comlab.ox.ac.uk> wrote:
> On Wed, 2009-02-04 at 17:35 -0800, Tyler Close wrote:
>> Hi all,
>>
>> I've been knee deep in Waterken server code for a few months now,
>> making some changes to make it perform better and be easier to review.
>> Anyways, I've finally gotten back to the stage where the next version
>> is in a usable state, and so I've been working on the new Javascript
>> interface. This version follows the ADsafe conventions and uses a
>> different syntax. There's a test page / tutorial at:
>>
>> https://vsci.hpl.hp.com/-/bang/#s=6ysjn2sjvwl35p
>>
>> I'm looking for some testing and criticism of the Javascript API.
>>
>
> Looking at it quickly, I think I prefer the old syntax. How come the
> change? What advantages does the new syntax have?
The _ convention in the previous syntax was not compatible with the
Google coding conventions, which use a trailing _ to denote a private
member field in an object.
With the previous syntax, there was also a danger that a programmer
would try to do an eventual operation without checking that the target
object was actually a promise (by passing it through the _()
function). In the current syntax, there's no way to write an eventual
operation that is not safe: all eventual operations are invocations on
the Q object.
ADsafe doesn't support freezing of an object, so separate clients of
the same promise could tamper with that promise's API, such as by
replacing the value of the promise's "post" member. With the current
API, it's not possible for ADsafe code to tamper with the behaviour of
a promise.
> Why the name Q?
Best we could come up with. Think of it as meaning: "This operation is
queued for later, not done now."
--Tyler
More information about the e-lang
mailing list