|
|
|
|
|
by talex5
4162 days ago
|
|
Note that the Lwt syntax extension (often used in Mirage) adds a try_lwt..finally construct. Doing anything at all with IO in Mirage will be asynchronous (there are no blocking operations anywhere). However, people generally use various "with" functions to manage resources. That's better than try..finally because the allocation can't get separated from the try bit. I never found Java checked exceptions much use for resource leaks, since unchecked exceptions are always still possible. |
|
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.