C Terminology – Can Data Hold Multiple Values?

cterminology

I'm a beginner and I'm following a course on C programming.
In my book,a variable is defined as a memory space that stores a single unit of data (datum).
Is a data structure considered to be a single unit of data (datum)?
Ex: struct Point single_point;

Best Answer

Is a data structure considered to be a single unit of data (datum)?

Well, sometimes yes, in the very abstract, but often no if you look under the hood.

... a variable is defined as a memory space that stores a single unit of data (datum) ...

But even that single unit of data usually consists of multiple individual binary bits, maybe multiple bytes or words. So it is really a matter of terminology, or more importantly, perspective, as to whether we consider one something a datum or data. It's both is probably the most complete answer.

I think the main point I'd like to make is that there are different points of view depending on who is looking at it.

Consider the nature of the client role relative to the implementation role -- one of the most important relationships in programming. We try to separate client from implementation using abstraction; this eases programming especially as programs get larger, and change over time.

From the high-level, client point of view many items might be considered a single abstraction, and thus, logically a datum, despite consisting of multiple individual bits of state.

However, under the hood and from the implementation perspective, the datum decomposes into an organization or composition of other items.

For example, an array of int's might be considered a single datum to one way of looking at it. But it is also a composition of multiple int's. A linked list or tree is an even more complex data structure (than an array), and typically consists of multiple independent memory blocks, so it is composed of multiple data. However, we can often treat a linked list or tree as an abstraction, for example, we can pass a whole tree by reference to another function with a single parameter. Thus, from another point of view it is logically a single entity (though definitely composed of multiple words of memory).

C has union's and struct's, which reflect sum types and product types in Algebraic Data Types. These may or may not be considered data structures: however, when most use the term data structure, they are evoking a more complex (and possibly algorithmic) entity (than a single a struct or union) composed of multiple structs linked to each other by references of some sort (e.g. pointers).

Note that regarding data structures the term Abstract Data Type comes up, which need to be differentiated from Algebraic Data Type (both abbreviated ADT). Abstract data structures support the client/implementation relationship (by abstraction, of course).

There is also mereology, which is the study of whole part composition, and is a recursive concept. A car is an entity in and of itself, however, can be decomposed into its parts. Mereology is the philosophical study of the various aspects and relationships between whole and part, and as such is apropos to the question about data vs. datum.

Related Topic