Memory safety depends entirely on GC ?

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Mon Feb 23 09:48:32 PST 2015


On 2/22/15 8:50 PM, deadalnix wrote:
> On Sunday, 22 February 2015 at 20:48:58 UTC, Andrei Alexandrescu wrote:
>>> What ??? That mean writing all library code twice, for client that want
>>> GC and for these who don't.
>>
>> I'm not 100% convinced but it seems to me RC vs. GC is a class design
>> time decision.
>>
>
> The right strategy for memory management depend on the usage you'll do
> of an object, not of the object itself.

I used to think the same. But then I considered typechecking things like:

class Widget
{
     private char name[1024];
     char[] getName() { return name[]; }
     ...
}

Such code is safe if Widget is a GC class but not if it uses reference 
counting.


Andrei



More information about the Digitalmars-d mailing list