Feature request: array stuff

Janice Caron caron800 at googlemail.com
Thu Apr 24 08:07:26 PDT 2008


I would like to be able to allocate a dynamic array on the stack.
The following compiles, but does not achieve the desired effect:

    int n = 100;
    scope array = new int[n];

The array is allocated on the heap, not the stack. I would like it to
be allocated on the stack.

I would also like to be able to create uninitialised dynamic arrays:

    // on the heap
    auto array = new int[n] = void;

    // on the stack
    scope array = new int[n] = void;

Note that the last one of these can be implemented in machine code
merely by decrementing the stack pointer! (Well - almost. array.ptr
and array.length would still need to be assigned, but I can live with
that).

Obviously, increasing the length of a scope array would have to be illegal!

Finally, I want to be able to increase the length of an array without
initialising the new elements:

    array.length = 100 = void;

(The syntax of the last one leaves a bit to be desired, but I can't
think of anything better off hand, right now).

Does anyone know if any or all of these are already the subject of
enhancement request? Does anyone else want any of these? Is there any
reason why I shouldn't add this to bugzilla?



More information about the Digitalmars-d mailing list