如何确定类型等价。命名和结构
How to determine Type equivalences. Named and Structural
以下声明是针对使用名称等价的语言给出的:
A, D: array [1..100] of int;
C: array [1..100] of int;
F: array [1..100] of int;
问题是:"Explain which of these four variables have the same type. Furthermore, which ones have different types?"
如何确定这种情况下的类型等价性?
我相信 A 和 D 是名称等价的——因为它们使用相同的赋值——但所有选项在结构上都是等价的,因为它们都使用 array [1..100] of int
.
类型的名称等价表示"structural equivalence without name substitution"*.
因为你所有的变量都具有结构上等价的类型,不包含任何不同命名的类型(它们不同的变量名和单独的声明与类型检查无关),它们的类型是名称等价的,即。 e. 四个变量的类型相同。
*http://web.eecs.utk.edu/~bvanderz/teaching/cs365Sp12/notes/types.html
以下声明是针对使用名称等价的语言给出的:
A, D: array [1..100] of int;
C: array [1..100] of int;
F: array [1..100] of int;
问题是:"Explain which of these four variables have the same type. Furthermore, which ones have different types?"
如何确定这种情况下的类型等价性?
我相信 A 和 D 是名称等价的——因为它们使用相同的赋值——但所有选项在结构上都是等价的,因为它们都使用 array [1..100] of int
.
类型的名称等价表示"structural equivalence without name substitution"*.
因为你所有的变量都具有结构上等价的类型,不包含任何不同命名的类型(它们不同的变量名和单独的声明与类型检查无关),它们的类型是名称等价的,即。 e. 四个变量的类型相同。
*http://web.eecs.utk.edu/~bvanderz/teaching/cs365Sp12/notes/types.html