Search code examples
arrayscobjectterminology

Difference between terminology : element vs member (of array)?


In the realm of computer science, is there a difference between element of the array vs member of the array? Is it interchangeable to a point the "correct" term is subject to each language's specification? Or do they each have different meaning? Is one correct/wrong?

I was taught myArray[1] is expressed as "second element of the array". But I have read/heard phrases similar to "member of the array". Reading the C Standards gave me the impression that arrays have "elements" and structs/unions have "members" more often. But then I did find the term "flexible array member" in the Standard too, so I got puzzled.

Practically in our workplace it may or may not make a difference and I wouldn't really mind if someone used the wrong term, but for this question I'm seeking the correct answer for a reason.


Solution

  • The official terminology reference is the ISO C Standard. It uses elements for arrays, and members for structs and unions. So should everybody else to avoid confusion.

    The "flexible array member" actually refers to a struct member that has array type. This is an example taken from the C11 Standard, section 6.7.2.1

    struct s { int n; double d[]; };
    

    Here, d is the flexible array member. The flexible array in turn has elements of its own (the number of which is not known yet, so the array is incomplete, which is why it's called flexible).