-
Notifications
You must be signed in to change notification settings - Fork 41
Add code example #150
base: master
Are you sure you want to change the base?
Add code example #150
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the intent. With the removal of non-EcmaScript jargon like "microtask checkpoint" this would LGTM. Thanks!
README.md
Outdated
} | ||
``` | ||
|
||
The guarantee goes away if any of the blanks (`[…]`) introduces a microtask checkpoint, for example if it contains an `await` expression, or if it wraps the remainder of the code in a promise callback (e.g. `Promise.resolve().then(() => […])`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
microtask checkpoint
This is not an EcmaScript concept.
or if it wraps the remainder of the code in a promise callback (e.g.
Promise.resolve().then(() => […])
)
probably worth saying somehow. But literally this doesn't make syntactic sense for the example code, as it is shown as straight-line code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is re-using the same "microtask checkpoint" terminology from the previous paragraph. It's indeed HTML spec jargon. I'm definitely open to rephrasing it to make it more general; could you recommend a better phrasing?
But literally this doesn't make syntactic sense for the example code, as it is shown as straight-line code.
It only makes sense if you think of each // […]
as an injection point where arbitrary text can go. One could then replace the first // […]
with:
Promise.resolve().then(() => {
...and the last // […]
with:
});
Any idea on how to make this more clear? Or should we just drop this particular example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is re-using the same "microtask checkpoint" terminology from the previous paragraph. It's indeed HTML spec jargon. I'm definitely open to rephrasing it to make it more general; could you recommend a better phrasing?
Thanks for pointing out the previous paragraph. That language needs to go too. EcmaScript has no tasks or microtasks. As of the last tc39 mtg, @littledan and I arrived at a mutual understanding about how to phrase all of this in terms of Job scheduling and Job execution. I'll first let @littledan speak for his memory of our mutual understanding and how it bears on this issue before making my own suggestions.
@littledan , did we record our mutual understanding? Was it in your subsequent talk slides? Meeting notes? Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any idea on how to make this more clear? Or should we just drop this particular example?
I see what you're doing and it is coherent and informative. However, you're filling in the [...]
s with unbalanced bracketing, which would change the indentation level. That's what's confusing. Although not an official part of the syntax, we all understand code in terms of indentation level.
Yes, I think the best thing is probably just to drop this particular example, assuming everyone understands the shown indentation level to rule it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing out the previous paragraph. That language needs to go too.
Did you see the previous paragraph? It explicitly points out that this is an HTML concept, which seems fine by me.
Either way, I'd love to hear more about the discussion you had with Dan. He's on vacation now so I imagine it'll take a while until we hear back.
I see what you're doing and it is coherent and informative. However, you're filling in the [...]s with unbalanced bracketing, which would change the indentation level. That's what's confusing. Although not an official part of the syntax, we all understand code in terms of indentation level.
Yes, I think the best thing is probably just to drop this particular example, assuming everyone understands the shown indentation level to rule it out.
Ack. Removed this example.
README.md
Outdated
} | ||
``` | ||
|
||
The guarantee goes away if any of the blanks (`[…]`) introduces a microtask checkpoint, for example if it contains an `await` expression, or if it wraps the remainder of the code in a promise callback (e.g. `Promise.resolve().then(() => […])`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is re-using the same "microtask checkpoint" terminology from the previous paragraph. It's indeed HTML spec jargon. I'm definitely open to rephrasing it to make it more general; could you recommend a better phrasing?
Thanks for pointing out the previous paragraph. That language needs to go too. EcmaScript has no tasks or microtasks. As of the last tc39 mtg, @littledan and I arrived at a mutual understanding about how to phrase all of this in terms of Job scheduling and Job execution. I'll first let @littledan speak for his memory of our mutual understanding and how it bears on this issue before making my own suggestions.
@littledan , did we record our mutual understanding? Was it in your subsequent talk slides? Meeting notes? Thanks.
README.md
Outdated
} | ||
``` | ||
|
||
The guarantee goes away if any of the blanks (`[…]`) introduces a microtask checkpoint, for example if it contains an `await` expression, or if it wraps the remainder of the code in a promise callback (e.g. `Promise.resolve().then(() => […])`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any idea on how to make this more clear? Or should we just drop this particular example?
I see what you're doing and it is coherent and informative. However, you're filling in the [...]
s with unbalanced bracketing, which would change the indentation level. That's what's confusing. Although not an official part of the syntax, we all understand code in terms of indentation level.
Yes, I think the best thing is probably just to drop this particular example, assuming everyone understands the shown indentation level to rule it out.
Note, the deref stability is still guaranteed as long as you don't return to the event loop. So |
Actually there currently is no longer such a guarantee in the spec text. The only constraint on the scheduling of the It is actually causing some confusion on testability in tc39/test262#2239 (comment) |
It's guaranteed on the web, given the form of the HTML integration. The current text implies that there always may be a collection when there is an await (a frequently repeated misconception), when embedding environments have the freedom to determine whether that's the case (and I would encourage others environments to align with the web here, for the same reasons we made the decision in that case). |
TBH, I still don't understand the reasoning for the timing guarantees of What is the advantage of guaranteeing Wouldn't it be simpler to say that Of course, the embedder is still free to keep objects alive longer than a synchronous execution if it wants. |
I would even recommend showing the pattern
as the canonical example and discuss that the scope of After that, one can discuss that there are guarantees about the return value of I think it is more robust to rely on the correct scoping of |
@sigurdschneider @mathiasbynens Are you planning on updating this code sample based on the comments in the review? |
@mathiasbynens Ping, would you be interested in fixing the error I mentioned in #150 (comment) ? |
WDYT? cc @sigurdschneider