Implicit alloca for static arrays
Craig Black
cblack at ara.com
Thu Mar 23 08:43:26 PST 2006
Agreed. Stack arrays are useful for efficiency reasons. It doesn't seem
like it would be hard for Walter to implement.
-Craig
"Lionello Lunesu" <lio at remove.lunesu.com> wrote in message
news:dvuf4v$1dra$1 at digitaldaemon.com...
> If you'd ask me, this should definately be included before 1.0:
>
> # void somefunc( uint i ) {
> # char[i] array; // creates static array but with run-time length (*)
> # }
>
> This can currently be done by using alloca (for the record:)
>
> # import std.c.stdlib;
> # void somefunc( uint i ) {
> # char[] array = (cast(char*)alloca(char.sizeof * i))[0..i];
> # }
>
> which works fine, as long as you don't append / resize the array.
>
> L.
>
> (*) this code generates 4 identical compiler errors:
> Integer constant expression expected instead of (events).length
>
>
More information about the Digitalmars-d
mailing list