r/cpp • • Sep 17 '22

Cppfront: Herb Sutter's personal experimental C++ Syntax 2 -> Syntax 1 compiler

https://github.com/hsutter/cppfront
335 Upvotes

360 comments sorted by

View all comments

Show parent comments

1

u/christian_regin Sep 20 '22

If only C# added RAII then it might be a decent language.

1

u/pjmlp Sep 21 '22

You have using for Dispose as pseudo destructor, then enable one of the Rosyln analysers that break the build when you forget to make use of it.

CA2000: Dispose objects before losing scope

1

u/christian_regin Sep 27 '22

using is a decent hack but it is not enough. For example if you have an object as a member that you want to be Disposed of when it's parent dies then you have to implement Disposable on the parent as well. It's not very pretty.

1

u/pjmlp Sep 27 '22

Just like RAII types as members only work as value types or explicitly placed into a smart pointer.

→ More replies (2)