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

bearophile via Digitalmars-d digitalmars-d at puremagic.com
Tue Apr 14 00:30:21 PDT 2015


John Colvin:

> The problem is that the size isn't necessarily known.

The size is generally known only at run-time, that's the point.


> I guess the compiler could put in a branch, but at that point 
> you'd probably want to give the programmer control and have a 
> way of making it explicit.

You don't forget to put branches added by the compiler, so it's 
safer.

Generally you prefer something that's guaranteed to be allocated 
on the stack when it's small and there's enough stack. An array 
allocation annotated with "scope", perhaps.

Bye,
bearophile


More information about the Digitalmars-d mailing list