1688 shaares
869 private links
869 private links
Huh! This is one question I've been thinking about since I learned some Assembly - why isn't there dynamically growing array on stack? This answer solved the mystery wonderfully:
- because stack grows backwards (from high to low), the array index cannot be 0, 1, ... if we want to make the array grow in the same direction as the stack. The index would have to be 0, -1, -2, ...
- You can't have more than one of such arrays for the array to be contiguous.
- The array cannot grow when there are any stack push operations (e.g. function call).