[heycam/webidl] Way to mark a method as "async" (#214)

It would be nice if WebIDL provided a means to mark a method as async, like:

```Java
interface Foo {
   async returnValue whatever(); 
}
```

I was reading the Web Payments spec and noticed that they are using exceptions and promises incorrectly (they try to throw exceptions before they return the promise). Something like the above would prevent such issues by implicitly returning the promise. Any thrown exceptions in the method's prose will then just be converted to rejections by the promise machinery. 

Furthermore, such methods could then use "await" semantics if they need to wait for other methods or even internal "promises", etc. 

So, like: 

> When `foo()` is called:
>  1.  If some condition, throw a WhatEvesError. 
>  2. If [[slot]] was not set, throw NotAllowedError.
>  3. Let x be there result of awaiting thing that happens in another thread (where "thing" runs in parallel). 
>  4. return x. 

And 4. nicely resolves the promise. Or some such. 

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/issues/214

Received on Monday, 31 October 2016 02:17:00 UTC