2026-10-06 15:01 UTC
You can’t, not in e.g. Java.
Replies (4)
-
@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
-
@WhyJiffie@sh.itjust.works 2026-10-08 23:54
java: try-with-resources, AutoClosable
-
@WhyJiffie@sh.itjust.works 2026-10-08 23:56
java: try-with-resources, AutoClosable