2 ms·
What if you want to move the ownership of the resource and let the new owner eventually to dispose it?
by ithkuil 4y ago
What if you want to move the ownership of the resource and let the new owner eventually to dispose it?
- whateveracct 4y agoThen withX isn't the right abstraction. The original situation (malloc gives you a linear variable) handles what you want. A function that takes the variable but does not return it effectively "takes ownership of it" and the type system will force a free. There's a "Linear Constraints" paper draft out there that emulates ownership and borrowing with linear types, and uses the titular new language feature to greatly improve ergonomics.