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 #534

Open
raynei86 opened this issue Sep 13, 2023 · 1 comment
Open

Add destructors to standard library objects #534

raynei86 opened this issue Sep 13, 2023 · 1 comment

Comments

@raynei86
Copy link

Abstract

ARC/ORC is already the default memory management technique on latest stable release, but the standard library hasn't followed and utilize destructors where plausible.

Motivation

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.

Code Examples

No response

Backwards Compatibility

No response

@Araq
Copy link
Member

Araq commented Sep 14, 2023

Calling close explicitly will continue to not be an error so that it's still easy to write code that works with the older GCs. No conditional compilation with when required.

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

No branches or pull requests

2 participants