4 ms·
Is it possible to allocate an object directly into a compact region, rather than allocating outside and then copying it in?
by logicchains 7y ago
Is it possible to allocate an object directly into a compact region, rather than allocating outside and then copying it in?
- rwmj 7y agoIf you explore ways it might work, I think you'll see that's not easy. For example, let's say you have an "alloc_compact" function. To put a tuple "directly" into the compact heap you might write: alloc_compact (1,2) But wait! You've actually allocated (1,2) and then copied it.
- kccqzy 7y agoNo. Putting an object in a compact region is more than just copying. It's also evaluating the data and making it immutable. Remember Haskell values are lazy, and therefore by default mutable. (Laziness is mutability, and evaluation is replacing the thunk by the normal form of data.)