Talk:Variable-length array
Appearance
stored where?
i think it is only on stack. but there might be cases where it is on heap due to size or just language way of dealing with ADT's. i ask for i added that it is typycally on stack onto main page. 84.16.123.194 (talk) 20:01, 23 October 2008 (UTC)
- Depends on the language and implementation. In C (C99), it's on the stack, i.e., VLAs can only have
auto
storage class. In COBOL, it's either theWORKING-STORAGE
orFILE
SECTION
s, which are static data areas, or in theLINKAGE
SECTION
, which may be static to another program module or allocated on the heap (e.g., usingEXEC
CICS
GETMAIN
). — Loadmaster (talk) 20:19, 23 October 2008 (UTC)- thanks. should it be mentioned here? 84.16.123.194 (talk) 21:33, 23 October 2008 (UTC)
Only automatic?
I wouldn't say that the term "variable length array" is limited to any one storage duration. I would consider the term entirely appropriate for any array of non-fixed size, including arrays allocated out of a heap or arrays (as in awk and Perl) with no fixed size. (In fact, I would consider the awk/Perl to be *true* variable-length arrays, whereas C99 has fixed-length arrays with the length determined at execution time.) Jordan Brown (talk) 21:03, 23 April 2009 (UTC)
- Of course, the length of dynamically allocated arrays (including resizable/dynamic arrays) doesn't have to be known at compile time, and you could trivially consider them to have a "variable length". But they are not what the term "Variable-length array" refers to, at least in the context of the C language. -- memset (talk) 12:21, 24 April 2009 (UTC)
- But the article mentions lanugages other than C, too. What to do? We don't want to duplicate the Dynamic memory allocation article. — Loadmaster (talk) 16:30, 14 October 2009 (UTC)