News for hackers. Stuff that matters.
Re:Lessons in Managing Haskell Memory by logicchains on Thursday April 09, 2020 @05:01AM (#22820881)
Is it possible to allocate an object directly into a compact region, rather than allocating outside and then copying it in?
Re:Lessons in Managing Haskell Memory by rwmj on Thursday April 09, 2020 @09:04AM (#22822114)
If 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.
Re:Lessons in Managing Haskell Memory by kccqzy on Thursday April 09, 2020 @02:07PM (#22825456)
No. 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.)