How usable is the D language without a garbage collector?

Era Scarecrow rtcvb32 at yahoo.com
Sat Jul 16 18:32:39 UTC 2022


On Friday, 15 July 2022 at 09:27:51 UTC, LinguisticMystic wrote:
> However, what confuses me is the fact that D has a  garbage 
> collector. My necessary requirement is that the runtime should 
> not include any such thing. And D does have some sort of @nogc 
> switch.

  The @nogc is primarily that you aren't allocating or handling 
anything that uses (*or may cause*) the GC to run. You might need 
@nothrow as well.

  Personally i love putting as much temporary allocations as i can 
on the stack, and leaving cleanup to instantly and cleanly be 
handled by the function cleanup code.

  In C/D one of my favorite things would be to allocate everything 
as a single block and then assign pointers as necessary so a 
single free will handle it rather than say 20-30.

  But if you aren't using the built-in array allocation, or an 
algorithm that will try to change the allocated memory then it 
should be fine. Not sure about the allocator template use, but 
doing structs and malloc/free should be a workable pair without 
relying on the GC at all.

  But i'm very rusty on all this anymore :(


More information about the Digitalmars-d mailing list