Why same pointer type for GC and manual memory?

IGotD- nise at nise.com
Tue Nov 19 21:58:05 UTC 2019


On Friday, 15 November 2019 at 11:32:07 UTC, Basile B. wrote:
>
> TBH I see your point but D is a system programming language. 
> Even if there's a GC you can also do Manual Memory Mangement 
> (sometimes you'll see "MMM "to refer to that in the forums), 
> RC, and you can also write custom machine code in asm blocks.
>
> In most of the case, if you just stick to the GC way, it'll be 
> alright, even if pointers are actual machine pointers, i.e 
> usable in asm blocks ;)
>
> Recently some guys have discovered however that an aggressive 
> anti virus scanner could cause problems...
>
> Anyway, just to say, D produces machine code and doesn't 
> requires a VM... if you need fat pointers for a custom memory 
> management, free to you.
>
> I don't think this will ever change.

Nim which is a systems programming language handles the GC part 
nicely.

With Nim you can plug and play many different types of GC types.

https://nim-lang.org/docs/gc.html

     --gc:refc Deferred reference counting with cycle detection, 
thread local heap, default.
     --gc:markAndSweep Mark-And-Sweep based garbage collector, 
thread local heap.
     --gc:boehm Boehm based garbage collector, stop-the-world, 
shared heap.
     --gc:go Go lang like garbage collector, stop-the-world, 
shared heap.
     --gc:regions Stack based garbage collector.
     --gc:none No garbage collector.

so the architecture of Nim allows this just by a compiler switch. 
Would D even support reference counting as Nim defaults to with 
the current mixup of raw and GC pointers?



More information about the Digitalmars-d-learn mailing list