D is our last hope

IGotD- nise at nise.com
Tue Dec 19 00:37:39 UTC 2023


On Monday, 18 December 2023 at 20:14:55 UTC, Walter Bright wrote:
> On 12/18/2023 3:12 AM, IGotD- wrote:
>> 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.
>
> I don't see the advantage of this.

The advantage is by forcing GC objects to be an actual object 
(class), you can modify the GC algorithm to whatever you want. 
Unlike today we're stuck with a rudimentary GC type that might 
deter a lot of potential users and use cases.


More information about the Digitalmars-d mailing list