Question

I have seen some definitions about basic data type, primitive data type, and built-in data type. But I am not sure yet, how can I say a data type is basic or primitive or even primitive basic!
Is there any good definition to help specify type of a data type in this way?

Wikipedia says that primitive data type consists of basic data type and built-in data type. foldoc.org says : "Some types are primitive - built-in to the language, with no visible internal structure".

I am really confused!

Was it helpful?

Solution

Citing from the book of Michael L. Scott, Programming Language Pragmatics, section 7.1.1 (The definition of Types), p.322:

There are at least three ways to think about types, which we may call the denotational, constructive, and abstraction-based points of view. [...] From the constructive point of view, a type is either one of a small collection of built-in types (integer, character, Boolean, real, etc.; also called primitive or predefined types), or a composite type created by applying a type constructor (record, array, set etc.) to one or more simpler types. (This use of the term "constructor" is unrelated to the initialization functions of C++ and Java. [...]

Therefore, from a theoretical POV, those terms (primitive, built-in, predefined - I will add basic too) are all more or less synonyms and they are all understandable in contrast with composite types, which are built from them using, possibly in a recursive manner, some kind of "operation on types" (an array of char, a collection of pointers, a list of records each consisting of a float and a string, etc.)

I agree with @KeithThompson that from a practical POV each language will use (some of) these terms assigning very specific meanings to them, thus you would have to browse the particular language specification to know what is meant in that context.

OTHER TIPS

A built-in data type is one that is available in the language and not added from a library or the code you write. Typically, this is the case for int or string.

As Wikipedia says: "Opinions vary as to whether a built-in type that is not basic should be considered 'primitive'", the definition of a primitive data type is not really clear. In my personal opinion, a primitive data type is the same as a basic data type, i. e. one that has no structure or sub-components. Again int is a good example, but string has sub-components (the different characters from which it is built). Another non-primitive type would be file, as this has some structure like a file name or path.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top