You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some ideas from my library that might be interesting:
Resources are always acquired in-order, and released in opposite order. Resources are also released in opposite order if during a sequence of resource acquisition, a certain resource failed to be acquired.
Resource acquisition may be parameterised by prior resources acquired
Originally this was based off the idea of letrec in various functional languages, but this was too difficult to make work in JavaScript's strict evaluation. So instead during the in-order sequence of resource acquisition, prior resources acquired can specialise subsequent resources acquired.
Resource releasers are parameterised by errors thrown during resource usage, however they themselves do not need to rethrow the error, and they can ignore the error. This is important in some cases where releasing the resource changes depending on if there was an error during usage.
The whole thing only uses arrow functions and async function generators. I did not use the async generator idiom explained in the README.md.
The usage of withF and withG are optional. In certain situations, these bracketing abstractions are too limiting, such as during tail call recursion or when using while loops. In those cases, users are supposed to directly use ResourceAcquire and ResourceRelease types and can manage resources procedurally.
It is intended that resource acquisition be compositional. So that some higher level resource can encapsulate the acquisition of multiple lower-level resources.
In our project, we are using all the features of the library, so everything has a usecase. See tests for further details.
The text was updated successfully, but these errors were encountered:
This is interesting, and thank you for the information. Unfortunately, we recently decided to reduce the proposal scope somewhat, and though we plan on continuing to support Symbol.asyncDispose and AsyncDisposableStack, we have decided to postpone support for an async using declaration to a follow-on proposal. I am closing this issue for now, but will keep it in mind for future reference.
One of the benefits of using is that you are still able to leverage break, continue, return, yield, and await without needing to completely rewrite your code to move it into a callback.
I only discovered this proposal recently, it looks pretty cool.
But I built a resource management library required by our project Polykey (https://github.com/MatrixAI/js-polykey) inspired by python's with context and haskell's bracketing pattern in TS here: https://github.com/MatrixAI/js-resources
Some ideas from my library that might be interesting:
letrec
in various functional languages, but this was too difficult to make work in JavaScript's strict evaluation. So instead during the in-order sequence of resource acquisition, prior resources acquired can specialise subsequent resources acquired.withF
andwithG
are optional. In certain situations, these bracketing abstractions are too limiting, such as during tail call recursion or when using while loops. In those cases, users are supposed to directly useResourceAcquire
andResourceRelease
types and can manage resources procedurally.In our project, we are using all the features of the library, so everything has a usecase. See tests for further details.
The text was updated successfully, but these errors were encountered: