我看过一些关于基本数据类型、原始数据类型和内置数据类型的定义。但我还不确定,我怎么能说数据类型是基本的或原始的,甚至是原始的基本类型!
有没有好的定义可以帮助以这种方式指定数据类型的类型?
维基百科说原始数据类型由基本数据类型和内置数据类型组成。 foldoc.org说:“某些类型是原始类型 - 内置于语言中,没有可见的内部结构”。
我真的很困惑!
最佳答案
引用 Michael L. Scott 的书《编程语言语用学》,第 7.1.1 节(类型的定义),第 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. [...]
因此,从理论 POV 来看,这些术语(原始、内置、预定义 - 我将添加基本 也)或多或少都是同义词,并且与复合类型相比,它们都是可以理解的,复合类型是使用(可能以递归方式)某种“类型操作”从它们构建的(一个字符数组、一个指针集合、一个由 float 和字符串组成的记录列表等)
我同意 @KeithThompson 的观点,从实际的 POV 来看,每种语言都会使用(其中一些)这些术语,并为其赋予非常具体的含义,因此您必须浏览特定的语言规范才能了解该上下文中的含义。
关于types - 对内置、基本和原始数据类型有更清晰的了解吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15965914/