types - 对内置、基本和原始数据类型有更清晰的了解吗?

标签 types primitive built-in

我看过一些关于基本数据类型原始数据类型内置数据类型的定义。但我还不确定,我怎么能说数据类型是基本的或原始的,甚至是原始的基本类型!
有没有好的定义可以帮助以这种方式指定数据类型的类型?

维基百科说原始数据类型由基本数据类型和内置数据类型组成。 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/

相关文章:

c++ - C++ 中的可变大小数据类型(int)

java - 为什么 charAt 的工作方式不同,具体取决于打印的数据类型

c# - GetBytes 函数如何工作?

python - 如果我将脚本命名为 'string.py' 或 'math.py',“导入”操作的行为会有所不同。为什么会这样?

bash - 如何利用 Bash 的 awsome dirs 内置命令来利用笨拙的 pushd 和 popd

c++ - 获取 C++ 中表达式的类型,包括引用

Haskell 无法创建 TypeClass 的实例

c++ - 根据模板变量类型执行不同的方法

javascript - 在 javascript 中是否使用过原始变量?