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.
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.
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