Migrating dmd to D?
jerro
a at a.com
Sun Mar 3 04:04:59 PST 2013
> Really what is needed is gc arrays and ngc arrays as well as
> other essential features. e.g., gc arrays would not be part of
> the core spec while ngc arrays would.
You can already use slices without a gc, like this:
T[] allocate(T)(int n)
{
return (cast(T*) malloc(T.sizeof * n))[0 .. n];
}
void deallocate(T)(ref T[] a)
{
free(a.ptr)
a = null;
}
Of course, you can not append to such slices or expand them
without a GC. It would be useful to have a @nogc flag which would
result in an error if a feature that needs a GC was used.
I think adding @nogc would be better than defining a "core spec",
because most D code does not need that feature. If we add a a
@nogc flag, the people that don't need it can just ignore its
existence and do not need to learn about it, but if we call the
subset of D that doesn't use a GC a "core spec", people will feel
that's something they need to learn, which will make the language
seem more complex.
More information about the Digitalmars-d
mailing list