Again, the `await?` is sugar for the following:

```js
const value = await? callback();

// as sugar for
let value = callback();
if ('then' in value)
  value = await value;
```

but since I've stated already I have no interest anymore in this proposal,
we can also stop explaining to each others things we know already.

Best Regards

On Fri, Oct 11, 2019 at 1:32 AM Tab Atkins Jr. <jackalm...@gmail.com> wrote:

> On Wed, Oct 9, 2019 at 11:17 PM Andrea Giammarchi
> <andrea.giammar...@gmail.com> wrote:
> > > What's the order of the logs?
> >
> > Exactly the same, as the `await?` is inevitably inside an `async`
> function which would grant a single microtask instead of N.
>
> I think you're misreading my example?  Check this out:
> http://software.hixie.ch/utilities/js/live-dom-viewer/saved/7271
>
> ```html
> <!DOCTYPE html>
> <script>
> function one() {
>   oneAsync();
>   w("one A");
> }
> async function oneAsync() {
>   await Promise.resolve();
>   w("one B");
> }
>
> function two() {
>   twoAsync();
>   w("two A");
> }
>
> async function twoAsync() {
>   // await? true;
>   w("two B");
> }
>
> one();
> two();
> </script>
> ```
>
> This script logs:
>
> ```
> log: one A
> log: two B
> log: two A
> log: one B
> ```
>
> A and B are logged in different order depends on whether there's an
> `await` creating a microtask checkpoint or not. `await? true` won't
> create a microtask checkpoint, so you'll get the two() behavior,
> printing B then A. `await? Promise.resolve(true)` will create one, so
> you'll get the one() behavior, printing A then B.
>
> > If `maybeAsync` returns twice non promises results, there is only one
> microtask within the async `tasks` function, that would linearly collect
> all non promises, so that above example could have 1, 2, max 4 microtasks,
> instead of always 4
> > .
> > To explain `await?` in steps:
> >
> >   * is the awaited value a promise? schedule microtask
> >   * otherwise schedule a single microtask if none has been scheduled
> already, or queue this result to the previous scheduled one
> >
> > This would grant same linear order and save time.
>
> Ah, your earlier posts didn't say that `await? nonPromise` *would*
> schedule a microtask in some cases! That does change things.  Hm, I
> wonder if this is observably different from the current behavior?
>
> ~TJ
>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to