Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am learning "Programming languages principles" and there is a lot of information about stuff which make up a programming language . Unfortunately every material I came across until now has a lot of technical jargon involved and is very difficult to understand (Atleast for a beginner sincerely trying to understand the topic on his own by reading the material) .

Can anyone explain me the "Subscript binding and array categories" in general .. The classification says there are five kinds of arrays -
1.Static array
2.Fixed stack-dynamic array
3.Stack dynamic array
4.Fixed heap dynamic array
5.Heap dynamic array

This is what I could understand from the definitions (almost on every article on this topic I came across) .

Static array - subscript ranges are statically bound and storage allocation is static.
I understood that the space for the array is allocated in memory at compile time (before run time) .

Fixed stack-dynamic array - subscript ranges are statically bound, but the allocation is done at elaboration time during execution.
Now I didn't understand anything . What is meaning of the italicized phrases

Stack-dynamic array - the subscript ranges are dynamically bound, and the storage allocation is dynamic “during execution.” Once bound they remain fixed during the lifetime of the variable.
I dont understand what is meant by being 'bound' ?

I should be able to understand the remaining two definitions if I understand these three .

I know I am asking a lot .
Thanks :)

Here's a link I recently came across which I find useful for this topic . Anyone interested in this topic , check it out . :)

share|improve this question
Could you try to describe what you think it means, in your own words, so we could confirm/deny or otherwise help you along in your thinking? – jcmeloni Mar 15 '12 at 14:31
@jcmeloni Ya sure . :) – jsp99 Mar 15 '12 at 14:32
up vote 3 down vote accepted

To elaborate DeadMG's answer, it sounds like they mean:

  1. Static array: an array whose size is known, and whose storage is allocated, at compile time. In C, you might write at global (file) scope:

    int static_array[7];
  2. Fixed stack-dynamic array: you know the size of your array at compile time, but allow it to be allocated automatically on the stack (the size is fixed at compile time but the storage is allocated when you enter its scope, and released when you leave it)

    void foo()
      int fixed_stack_dynamic_array[7];
      /* ... */
  3. Stack dynamic array: you don't know the size until runtime, eg. C99 allows this:

    void foo(int n)
      int stack_dynamic_array[n];
      /* ... */
  4. Fixed heap dynamic array: same as the 2 except using explicit heap allocation

    int * fixed_heap_dynamic_array = malloc(7 * sizeof(int));
  5. Heap dynamic array: you can probably guess this:

    void foo(int n)
      int * heap_dynamic_array = malloc(n * sizeof(int));

Is this the same book as Concepts of Programming Languages? Because again, these aren't a useful classification of types, they only address the allocation mechanism. Once you pass any of these "different" things into a function, their classification under this scheme is irrelevant.

share|improve this answer
Robert.W.Sebesta Principles of programming languages . I thought its a nice book :/ . Thanks for explaining it so well . Ya,it would be nice if you elaborate others as well . :) – jsp99 Mar 15 '12 at 15:45
@ Useless .. Yes it is !! – jsp99 Mar 16 '12 at 11:51
I have few questions . Can you clear them :) ? – jsp99 Mar 16 '12 at 12:24
1. So , the usual array I declare in C (in main() function) is a fixed stack dynamic array , right ? 2 . And is it a mistake that you did with fixed heap dynamic array ? What if the statement is declared globally . ? – jsp99 Mar 16 '12 at 12:40
The fixed bit just means you know the size is fixed, so 4 and 5 would be identical if you can prove n == 7 at compile time. Declaring globally or locally makes no real difference under this terminology. – Useless Mar 16 '12 at 13:05

The classification is wrong. They are all arrays, and of fixed size. The only thing that changes is the memory region where they are allocated, and sometimes, the fixed size doesn't need to be known until runtime. These are not type-changing properties. All of those things are the exact same thing- an array.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.