3 ms·
> Note that the Lwt syntax extension (often used in Mirage) adds a try_lwt..finally construct. That's what I wanted to say, but reading back, it was a bit uncl
by mercurial 12y ago
> Note that the Lwt syntax extension (often used in Mirage) adds a try_lwt..finally construct.
That's what I wanted to say, but reading back, it was a bit unclear. Though I'd recommend lwt.ppx over its camlp4 ancestor...
> However, people generally use various "with" functions to manage resources.
Which I assume are usually implemented via try/finally if using Lwt :)
> I never found Java checked exceptions much use for resource leaks, since unchecked exceptions are always still possible.
It's not fool-proof, but having a codebase where most exceptions are checked exceptions still protects you in many cases. And of course, try-with-resource is a good way to guarantee against resource leaks in the majority of cases.