2026-10-06 15:01 UTC
You can’t, not in e.g. Java.
Replies (2)
-
@ChairmanMeow@programming.dev 2026-10-06 16:12
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.
-
@calcopiritus@lemmy.world 2026-10-07 05:26
You can do some kind of RAII in python with the with keyword. Only works for local variables though, where it’s easy to free resources manually