R
Rui Maciel
jacob said:If you know that your data will almost never go beyond 200 you will
almost always win, without EVER having a HARD-WIRED limit and using
almost always a fast stack allocation.
I didn't stated that VLAs are all evil, all the time. They can be handy in
some cases, including the ones you pointed out. I believe VLAs usefulness
shines through in cases where a fixed size array is declared with a size
large enough to fit every conceivable need, and replacing it a VLA will make
it possible to save a bit of memory.
In spite of that, VLAs tend to be sold as what they are not: a sort of
malloc() replacement which has all the advantages (fast, easy to use, no
need to manage memory, etc...) and absolutely zero disadvantages. The www
is packed with sites showcasing how VLAs are so perfect in every conceivable
scenario based on examples which are a bit worrisome, such as using them to
define dense matrices of an undetermined size and buffers without any size
cap. I won't be surprised if in the near future the "C is inherently
unsafe" mantra will resurface based solely on how VLAs are being marketed
right now and, as a consequence, how they are/will be employed.
Rui Maciel