bearophile wrote:
Andrei Alexandrescu:
The possibility of using D without a garbage collector was always
looming and has been used to placate naysayers ("you can call malloc if
you want" etc.) but that opportunity has not been realized in a seamless
manner. As soon as you concatenate arrays, add to a hash, or create an
object, you will call into the GC.

One simple possible solution: -nogc is to write C-like programs, with no automatic reference 
counting. It doesn't include the GC in the final executable (making it much smaller) and in such 
programs AAs and array concatenation and closures are forbidden (compilation error if you try to 
use them). "New" allocates using the C heap, and you have to use "delete" 
manually for each of them.
This is simple. While adding a second memory management system, ref-counted, 
looks like an increase of complexity for both the compiler and the programmers.

I was thinking of starting from the opposite end - add the required tools first so we gain experience with them, and then integrate with the compiler.

1. Put array definitions in object.d. Have the compiler rewrite "T[]" -> 
".Array!(T)"<

That has to be done with care an in a transparent way, not adding the Array 
name in the namespace, so you can create an Array youself, etc.

There shouldn't be any harm in using Array or AssocArray directly.


Andrei

Reply via email to