3 ms·
Back in the 90s there was some work on "region-based memory management", which is kindof this. The type of every function that allocates memory is parameterized
by vilhelm_s 8y ago
Back in the 90s there was some work on "region-based memory management", which is kindof this. The type of every function that allocates memory is parameterized on a region to allocate it, and the type of every value is tagged with the region it was allocated in. It's then possible to use something similar to the Hindley-Milner algorithm to infer what the regions should be. At the point when Hindley-Milner would generalize to make a polymorphic type, you know that the corresponding region variable is no longer "leaking", so you can insert the operations to allocate/free it.
http://www.elsman.com/mlkit/pdf/toplas98.pdf http://www.elsman.com/mlkit/pdf/toplas98.pdf