3 ms·
> I desperately wish that languages would make this a compile error if all code paths don't lead to the resource being freed. You might want to take a look at
by lixtra 6y ago
> I desperately wish that languages would make this a compile error if all code paths don't lead to the resource being freed.
You might want to take a look at rust.
- AtlasBarfed 6y agoI can see the obvious parallels between memory management lifetimes and transaction management, does rust have explicit features for extending lifetimes to resources besides memory?
- lixtra 6y agoYes, it works for files, network connections and database transactions[1]. To span a transaction over two functions, it has to be assigned to some variable and the lifetime of this variable is tracked by the compiler. [1] https://docs.rs/sqlx/0.3.0/sqlx/struct.Transaction.html https://docs.rs/sqlx/0.3.0/sqlx/struct.Transaction.html