Does 'D' language supports 'C' like VLA?

Jacob Carlborg via Digitalmars-d digitalmars-d at puremagic.com
Tue Apr 14 03:10:23 PDT 2015


On 2015-04-14 11:50, "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm at gmx.net>" 
wrote:

> It does work like that, but I don't see a way to pass the length to the
> alloca() call. Unfortunately, we can't refer to other parameters. It
> that were possible, it would indeed work:
>
> import core.stdc.stdlib : alloca;
> T[] stackArray(T)(size_t len, T* p = cast(T*) alloca(len * T.sizeof)) {
>          return p[0 .. len];
> }

Oh, I thought that would work.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list