-nogc
Leandro Lucarella
llucax at gmail.com
Thu Apr 23 09:09:11 PDT 2009
bearophile, el 23 de abril a las 07:08 me escribiste:
> 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 definitely agree that -nogc should not imply reference counting garbarge
collection.
Now in Tango/Druntime you already can use a dummy GC that all it does is
calling C malloc/free for gc_malloc/gc_free, exactly for this purpose, so
what -nogc should do in that case is just link against the "stub" GC
instead to the "basic".
> >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.
srd.array.Array can be used, and leave T[] as a syntax sugar only (but you
could also write std.array.Array!(T) instead).
--
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
More information about the Digitalmars-d
mailing list