← Back to context

Comment by randomNumber7

7 hours ago

As far as I know many C programmers think the addition of variable length arrays in C99 was a mistake. What would be the downside of this approach?

So much so, that it was made optional annex in C11, while Google paid to remove all their use from the Linux kernel.

I do not get the connection with a VLA in this context, but if you need a VLA, by all means use it. It is basically always better than the alternative.

  • > I do not get the connection with a VLA in this context

    The article uses a struct with a VLA as the last element.

    • I see. This array of unknown length at the end of a struct is called a flexible array member and not a variable length array (although it also refers to an array of variable length it is a different language feature).

      6 replies →

VLAs are anti C. I also dont even think _Generics should be in the complier. The complier should do minimal processing of syntax in terms of decision making, with only focus on being optimizing code.

Because in the flip side, you get C++ templates, which are turing complete, so you can write entire program syntax that the compliler executies during the complie process.