2026-10-06 16:12 UTC
It’s not impossible, at least in C# I know you can mark objects that need to be RAII with some custom attribute and enforce correct usage patterns with a custom analyzer. You need to write it yourself but it’s not impossible that way.
Replies (1)
-
@tias@discuss.tchncs.de 2026-10-06 18:16
Maybe you’re thinking of IDisposable with the using keyword. The problem with that is that you have to remember to use it in every call site. Nothing stops a caller from writing var x = new Foo() and walking away.