Skip to content
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

Add destructors to standard library objects #22695

Closed
raynei86 opened this issue Sep 12, 2023 · 2 comments
Closed

Add destructors to standard library objects #22695

raynei86 opened this issue Sep 12, 2023 · 2 comments

Comments

@raynei86
Copy link
Contributor

raynei86 commented Sep 12, 2023

Summary

Many standard library objects and containers still require close() to be called manually.
This is mostly alleviated with defer, but you still need to remember to close it.
This also isn't consistent with how some parallelization related modules have a =destroy hook.

Description

Provide destructors for standard library modules so cleanup is done automatically.
This should also simplify many parsers in the standard library since they all use std/streams and need to call close(); they also have many short functions that just opens a stream, then closes it two lines afterwards. Having a defer there breaks the succinct flow.

Alternatives

No response

Examples

No response

Backwards Compatibility

No response

Links

No response

@Araq
Copy link
Member

Araq commented Sep 13, 2023

That's a good idea but should be moved to the RFCs repo.

@raynei86
Copy link
Contributor Author

raynei86 commented Sep 13, 2023

Got it, moved issue to here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants