News for hackers. Stuff that matters.
Re:Mark–Scavenge: Waiting for Trash to Take Itself Out by fanf2 on Sunday November 24, 2024 @03:26PM (#42230236)
C, C++, Rust, Zig, …
Re:Mark–Scavenge: Waiting for Trash to Take Itself Out by eikenberry on Sunday November 24, 2024 @09:22PM (#42232629)
What's Zig's notation for it?
Re:Mark–Scavenge: Waiting for Trash to Take Itself Out by masklinn on Monday November 25, 2024 @01:15AM (#42233718)
Not doing anything, same as the other 3.

Heap allocation is what requires requesting memory from an allocator.

Re:Mark–Scavenge: Waiting for Trash to Take Itself Out by eikenberry on Monday November 25, 2024 @01:30PM (#42238717)
Right.. been using GC languages to long. Everything allocated to the stack unless it is specifically allocated to the heap. I was stuck thinking about what the keywords were. But I'm still curious.. are there any GC languages that have a way to specify if something should go on the stack or the heap?
Re:Mark–Scavenge: Waiting for Trash to Take Itself Out by masklinn on Monday November 25, 2024 @04:04PM (#42240182)
> are there any GC languages that have a way to specify if something should go on the stack or the heap?

I think only in the sense that some GCd language have value (stack) types as a separate hierarchy from heap types? E.g. structs in C# or Swift are stack-allocated (and value-identity, and copied) whereas classes are heap-allocated.

Adding that for java is one of the goals of Project Valhalla I believe.

Re:Mark–Scavenge: Waiting for Trash to Take Itself Out by stassats on Monday November 25, 2024 @11:01PM (#42242483)
Common Lisp. The dynamic-extent declaration allows for stack allocation.
Re:Mark–Scavenge: Waiting for Trash to Take Itself Out by im3w1l on Monday November 25, 2024 @11:15PM (#42242541)
I'm not sure about Zig, but what strikes me about the others are that they change the type of the object.

T vs T*.

It would be kind of neat if you could have an annotation on the variable instead that didn't change the type.

You could in C++ make a reference T& which is almost that - references behave identically to the real thing. But I think freeing the memory backing a reference is probably quite questionable?