Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How should web standards use the new JavaScript Symbol.dispose protocol? #794

Closed
littledan opened this issue Dec 7, 2022 · 0 comments
Closed

Comments

@littledan
Copy link

Wotcher TAG!

The JavaScript explicit resource management proposal by Microsoft's @rbuckton, at Stage 3 in TC39, defines a new protocol with a method called [Symbol.dispose] for resource cleanup. There is a nice syntax using resource = expr; which calls resource[Symbol.dispose]() at the end of the lexical scope--analogous to C++ RAII, Go defer, Python with, etc.

I'm filing this issue not to ask for a TAG review of that proposal (this could be done separately) but to start the discussion about how Web Platform APIs should use this new protocol. Many of the motivating use cases are for server environments, but many web APIs may also tie into this protocol--one idea described here.

Another place we're discussing this topic is whatwg/html#8557 . Note the question raised there about how cancellation and disposal should relate. In some mechanical sense, the APIs are dual of each other--for each void-returning API that takes an AbortSignal as a parameter, it would be equivalently expressive for that API to return an object representing the ongoing operation which could instead be disposed to unsubscribe/cancel. However, in many other programming environments, the semantics of cancellation and disposal are very different; for that reason, the integration proposed in the JS proposal readme does not mention cancellation.

It would be ideal if the TAG design principles contained clear guidelines to be used across the web platform to explain the appropriate way to design APIs using Symbol.dispose and/or AbortSignal.

@w3ctag w3ctag locked and limited conversation to collaborators Jan 4, 2023
@torgo torgo converted this issue into discussion #800 Jan 4, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants