Hacker News new | past | comments | ask | show | jobs | submit login
What polymorphism and garbage collection have in common (2013) (okmij.org)
100 points by g0xA52A2A on Nov 18, 2018 | hide | past | favorite | 3 comments



The main thing is that the less you care about performance, the more useful they both are. And vice versa.


Is there a more direct way to encode garbage collection in type unification without separate treatment?

Eg can you chain pure fuctions together that pass a world(memory block) around inside of some user defined monad that does the memory management/garbage collection for you?


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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: