Memory safety depends entirely on GC ?

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Mon Feb 23 16:59:51 PST 2015


On Monday, 23 February 2015 at 17:48:27 UTC, Andrei Alexandrescu 
wrote:
> 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.
>

This is not a valid argument against my point, simply expressing 
difficulties of implementation and lack of imagination of what 
this implementation can be.

I'm not sure how to convey the idea anymore. That is an ownership 
issue and solutions exist for it. Several of them have been 
proposed already.

It feels like we are gonna add a bazillion of stupid hacks to 
work around not introducing ownership into D. The return ref 
thing is one of them. What you are suggesting for refcounting is 
another.


More information about the Digitalmars-d mailing list