In an affine type system, every variable is used at most once. But C++ instantiations for RAII are not destructed more than once. Each instantiation has exactly one destruction.
In an affine type system, every variable is used at most once. But C++ instantiations for RAII are not destructed more than once. Each instantiation has exactly one destruction.
You might be interested in [0].
Affine logic rejects only the contraction rule [1]; unlike linear systems still has weakening [2].
[0]: https://en.wikipedia.org/wiki/Substructural_type_system
[1]: https://en.wikipedia.org/wiki/Idempotency_of_entailment
[2]: https://en.wikipedia.org/wiki/Monotonicity_of_entailment
Aside from actually having it integrated to the type system, Rust does exactly that. RAII is not linear.
> But C++ instantiations for RAII are not destructed more than once.
That's also what happens in Rust, it's not a linear type system.