4 ms·
I completely agree they're not the same things, but you can sort of see the "linear type" notion of "one and only one use" in RAII. Every construction has exact
by clord 9y ago
I completely agree they're not the same things, but you can sort of see the "linear type" notion of "one and only one use" in RAII. Every construction has exactly one use (destruction.) it's fairly easy to see that RAII is a very limited version of a linear type system.
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.
- masklinn 9y ago> Every construction has exactly one use (destruction.) it's fairly easy to see that RAII is a very limited version of a linear type system. 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.
- OJFord 9y ago> easy to see that RAII is a very limited version of a linear type system. 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 https://en.wikipedia.org/wiki/Substructural_type_system [1]: https://en.wikipedia.org/wiki/Idempotency_of_entailment https://en.wikipedia.org/wiki/Idempotency_of_entailment [2]: https://en.wikipedia.org/wiki/Monotonicity_of_entailment https://en.wikipedia.org/wiki/Monotonicity_of_entailment