Hypothesis: C is a mid-level language, and the standardization committee did not want to include operations in the base language (counting the library as a separate language) that perform a volume of work that was not determined at compile time.
All the basic C operations that come to my mind at the moment (maybe someone will correct me) require only a certain amount of work defined at compile time: calling a function, multiplying two numbers, assigning a structure to another, and soon. All of them can be executed with the execution of several machine instructions, which are fixed during compilation.
Even to allocate space for a variable-length array, only compilation time is required: calculate the size and subtract it from the stack pointer. In contrast, initializing all of this space requires some work at runtime. This is not consistent with the nature of C.
Library programs may require some workload defined at runtime, such as memset
.
source share