C99 doesn't need function bodies, or 'VLAs are Turing complete'
1–10 of 257 posts
Re: C99 doesn't need function bodies, or 'VLAs are Turing complete'
#2Re: C99 doesn't need function bodies, or 'VLAs are Turing complete'
#3Similar to making all your computations in the expressions for default arguments in python (and/or C++) and leaving the function bodies empty. Fancy, but not that mindboggling. What may surprise people is how and when these expressions are evaluated since they differ between languages.
I'm uneasy about variable-length arrays at the best of times. It hadn't even occurred to me that you might have a variable-length array as a function argument.
Re: C99 doesn't need function bodies, or 'VLAs are Turing complete'
#4Re: C99 doesn't need function bodies, or 'VLAs are Turing complete'
#5Re: C99 doesn't need function bodies, or 'VLAs are Turing complete'
#6Additionally Google spent several years paying to clean up the Linux kernel from all VLA occurrences.
Re: C99 doesn't need function bodies, or 'VLAs are Turing complete'
#7Similar to making all your computations in the expressions for default arguments in python (and/or C++) and leaving the function bodies empty. Fancy, but not that mindboggling. What may surprise people is how and when these expressions are evaluated since they differ between languages.
It might not be mind-boggling , but it is highly unusual to people who "think in C". This is not C! This kind of stuff is why purists stick to C89. I'm uneasy about variable-length arrays at the best of times. It hadn't even occurred to me that you might have a variable-length array as a function argument.
In the function definition, it seems to basically also decay to a pointer, except that the compiler adds basically an assertion that the value in the brackets is greater than zero to the to the top of the function. That actually seems quite weird to me.
I'd have been fine with the VLA acting like a proper local VLA with respect to things like sizeof, in which case the assertion makes sense. Or I'd have also been fine with it totally decaying to a pointer, making it just documentation. This half-way in between state is quite weird.
Re: C99 doesn't need function bodies, or 'VLAs are Turing complete'
#8But why? Why is this VLA parameter defined this way? It seems totally bizarre and unnecessary, but I suppose it must have been added to the standard to solve some kind of problem? Is the proposal for this feature available and gives some insight?
[1] https://www.open-std.org/jtc1/sc22/wg14/www/wg14_document_lo...
Re: C99 doesn't need function bodies, or 'VLAs are Turing complete'
#9It's a landmark and incredible language, but it's chock full of potholes and foot-shotguns (footguns that blow off your entire leg). Even huge companies can't get it right, which makes sense. It started as a language basically without guardrails, and because of the extreme deference to the holy backward compatibility, it's more or less always going to be that.
Re: C99 doesn't need function bodies, or 'VLAs are Turing complete'
#10Similar to making all your computations in the expressions for default arguments in python (and/or C++) and leaving the function bodies empty. Fancy, but not that mindboggling. What may surprise people is how and when these expressions are evaluated since they differ between languages.
It might not be mind-boggling , but it is highly unusual to people who "think in C". This is not C! This kind of stuff is why purists stick to C89. I'm uneasy about variable-length arrays at the best of times. It hadn't even occurred to me that you might have a variable-length array as a function argument.