D is our last hope
IGotD-
nise at nise.com
Mon Dec 18 11:12:59 UTC 2023
On Monday, 18 December 2023 at 05:46:20 UTC, Walter Bright wrote:
>
> I often use a mix of gc and malloc in a program - they each
> have their uses. It's sort of like using a struct or using a
> class - they coexist fine, and you can mix and match as you
> please.
>
> Rust also has both safe and unsafe code.
Have you ever thought about keeping the raw pointers as they are.
Classes are references types that are allocated using GC. Structs
are value types that cannot directly be allocated using GC. If
you want to allocate a struct using GC they need to be
encapsulated in a GC object. Manual heap allocation are entirely
done with raw pointers as before.
This is essentially what Swift does, classes are references types
that are allocated using GC and structs are value types that you
cannot directly allocate on the heap or GC on its own.
This change is breaking change but can be done. A few standard
library types must be rewritten though but that is under the hood
not so exposed to the programmer.
More information about the Digitalmars-d
mailing list