purescript-native icon indicating copy to clipboard operation
purescript-native copied to clipboard

Safe heap allocation via ST

Open paf31 opened this issue 9 years ago • 2 comments

This is not my area of expertise, but it seems like ST would be a nice way to use the type system to avoid reference counting. Would this be possible?

The idea is that we would malloc and delete the appropriate things in runST, and stack allocate everything else.

I'm not sure how this would affect things like sharing in data structures.

paf31 avatar May 23 '15 20:05 paf31

I think using something like this as a memory management option is a great idea. I've also wondered about the use of effects for it too. The plan is definitely to have a default memory management mechanism in place, but to allow such alternatives (as well as something like the Boehm libgc or other GCs).

FYI, reference counting is currently only used for data and records, everything else is handled by value (i.e. on the stack).

andyarvanitis avatar May 26 '15 23:05 andyarvanitis

This should be pretty easy to do now: https://github.com/andyarvanitis/pure11/wiki/Memory#unmanaged-data

andyarvanitis avatar May 13 '16 01:05 andyarvanitis