Tsoding streamed about D

Walter Bright newshound2 at digitalmars.com
Sat Mar 29 03:27:24 UTC 2025


On 3/25/2025 4:19 AM, Mike Shah wrote:
> Indeed, I wrote my own 'DynArray' type for use in betterC. Declaration is with 
> 'DynArray!int intArray' for example. I then used overloads for opSlice and such 
> to get pretty much the same functionality (e g. auto slice = intArray[2..4]). I 
> can also wrap that with a reference counted type to help avoid leaks if lifetime 
> and scope varies :)

Several of us studied reference counting for a while, and came to the 
unfortunate conclusion that is wasn't practical to make it memory safe without a 
GC or a borrow checker. Ref counting also has performance issues.

(Holding a non-refcounted reference to the payload of a refcounted object runs 
the risk of becoming a dangling pointer, but if that is disallowed, performance 
problems ensue.)

I use allocated slices all the time that don't use the GC, but I take care to 
manage the memory manually.



More information about the Digitalmars-d mailing list