dsherret / dsherret/using_statement

Dispose multiple resources in a single statement

Open
#1 2 comments 2 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
69
Forks
2
PR merge metrics
No merged PRs in 30d

Description

```ts
using(new Camera(), new Camera(), (cameraA, cameraB) => {
outputPicture(cameraA.takePictureSync());
outputPicture(cameraB.takePictureSync());
});
```

Edit: Should be https://github.com/dsherret/using-statement/issues/1#issuecomment-543441851

This is inspired by https://github.com/tc39/proposal-explicit-resource-management

```ts
// avoids leaking `a` or `b` to outer scope
// ensures `b` is disposed before `a` in case `b` depends on `a`
// ensures `a` is disposed even if disposing `b` throws
try (const a = ..., b = ...) {
...
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.