types - 内在类型与原始非内在类型

标签 types fortran primitive primitive-types

我在 fortran 中遇到过“内在类型”这个词,我以前从未听说过:

Fortran has five intrinsic data types: integer, real, complex, logical, and character.

内在与“原始”是同一个东西,还是在含义上有细微的差别?内在类型的反义词是什么(我想像日期或小数之类的东西):那会被称为什么?

最佳答案

Fortran 标准将内在(通常,不仅针对类型)定义为:

1.3.93

intrinsic

type, procedure, module, assignment, operator, or input/output operation defined in this part of ISO/IEC 153917 and accessible without further definition or specification, or a procedure or module provided by a processor but not defined in this part of ISO/IEC 1539.

此外,它定义了内部类型如下:

1.3.147.8

intrinsic type

type defined by this part of ISO/IEC 1539 that is always accessible.

因此,内部类型和派生类型之间的主要区别在于,您必须导入库才能使用最后一个类型。 (我之前已经使用 ISO_FORTRAN_ENV 库中的 real(real64) 制作了一个非内在示例,但正如 francescalus 在评论中指出的那样,情况并非如此。 )

您可能还想检查标准的第 4.4 节,它专门详细讨论了内部类型。 Fortran 标准 copy I have是非官方的,不是最新的,但最新的与旧的兼容,作为 Fortran 哲学的一部分。

我在 Fortran 标准中没有找到任何与 primitive 匹配的内容,因此我相信 Fortran 中未使用此命名法。我还检查了 C 标准,但找不到任何官方的东西,但是我在其他语言中找到的该术语的每个定义(例如 Java 中)基本上将其定义为该语言附带的类型,即内在类型。 :)

也许您正在寻找的区别是,虽然 real 是 Fortran 中的内在类型,但 double precision 不是:

The type specifier for the real type uses the keyword REAL. The keyword DOUBLE PRECISION is an alternative specifier for one kind of real type. If the type keyword REAL is used without a kind type parameter, the real type with default real kind is specified and the kind value is KIND (0.0). The type specifier DOUBLE PRECISION specifies type real with double precision kind; the kind value is KIND (0.0D0). The decimal precision of the double precision real approximation method shall be greater than that of the default real method.

但是,在其他语言中,shortlong 等类型可能会被理解为不同的基元。

关于types - 内在类型与原始非内在类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59940597/

相关文章:

c# - 如何从类型获取 TryParse 方法?

c++ - 从传递的 FORTRAN 数组生成 CUSP coo_matrix

java - 如何确定字符串表示中的基元类型?

java - Java 和 C++ 中的简单变量

c - 什么是无符号数据类型?

c - 使用宏进行类型检查

fortran - OPEN语句中的FORM ="FORMATTED"是什么意思?

作为输出参数的函数

iphone - 如何测试 Objective-C 中的原语是否为 nil?

scala - Scala 中 Object 和 AnyRef 的区别