Memory safety depends entirely on GC ?

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Tue Feb 24 12:52:38 PST 2015


On 2/24/2015 10:00 AM, Andrei Alexandrescu wrote:
> I also owe you apologies for not acknowledging that work. I find the proposal
> too complicated for what it provides and that's the short and long of it. It's
> easy to make a large and complex language addition to support any sensible
> abstraction. That doesn't make it automatically good.

My criticisms of it centered around:

1. confusion about whether it was a storage class or a type qualifier.

2. I agree with Andrei that any annotation system can be made to work - but this 
one (as are most annotation systems) also struck me as wordy, tedious, and 
aesthetically unappealing. I just can't see myself throwing it up on a slide and 
trying to sell it to the audience as cool.

3. In line with (2), I want a system that relies much more on inference. We've 
made good progress with the existing annotations being inferred.

4. I didn't see how one could, for example, have an array of pointers:

     int*[] pointers;

and then fill that array with pointers of varying ownership annotations.

5. The (4) homogeneity requirement would mean that templated types would get new 
instantiations every time they are used with a different ownership. This could 
lead to massive code bloat.

6. The 'return ref' scheme, which you have expressed distaste for, was one that 
required the fewest instances of the user having to add an annotation. It turned 
out that upgrading Phobos to this required only a handful of annotations.

7. 'return ref' makes memory safe ref counted types possible, finally, in D, 
without needing to upend the language or legacy code. And as the example I 
posted showed, they are straightforward to write. Only time and experience will 
tell if this will be successful, but it looks promising and I hope you'll be 
willing to give it a chance.


More information about the Digitalmars-d mailing list