[论文解读] An Overview of Nominal-Typing versus Structural-Typing in Object-Oriented Programming (with code examples)
本文提出了一种数学模型 NOOP,形式化了面向对象编程中的名义类型系统,证明了主流名义类型语言中继承与子类型之间的等价性。通过概念定义和代码示例,对比了名义类型与结构类型,为理解 OOP 类型系统设计奠定了基础。
NOOP is a mathematical model of nominally-typed OOP that proves the identification of inheritance and subtyping in mainstream nominally-typed OO programming languages and the validity of this identification. This report gives an overview of the main notions in OOP relevant to constructing a mathematical model of OOP such as NOOP. The emphasis in this report is on defining nominality, nominal typing and nominal subtyping of mainstream nominally-typed OO languages, and on contrasting the three notions with their counterparts in structurally-typed OO languages, i.e., with structurality, structural typing and structural subtyping, respectively. An additional appendix demonstrates these notions and other related notions, and the differences between them, using some simple code examples. A detailed, more technical comparison between nominal typing and structural typing in OOP is presented in other publications.
研究动机与目标
- 通过数学模型形式化主流名义类型 OOP 语言中继承与子类型之间的关系。
- 定义并对比面向对象类型系统中的名义类型、名义子类型与名义性,及其与结构对应物的差异。
- 在主流面向对象语言中,明确说明名义类型与结构类型之间的区别。
- 通过附录中的示例代码阐明差异。
- 为后续在 OOP 中对名义类型与结构类型进行技术性比较奠定基础。
提出的方法
- 开发 NOOP 模型,作为名义类型 OOP 的正式数学框架。
- 将名义性定义为基于显式声明和名称的类型属性。
- 通过基于名称的类型等价性与继承关系,形式化名义类型。
- 基于名称与结构的类型兼容性规则,对比名义子类型与结构子类型。
- 使用附录中的代码示例,阐明类型兼容性与继承中的差异。
- 通过形式化推理,确立在名义类型系统中将继承等同于子类型的合理性。
实验结果
研究问题
- RQ1在类型身份与兼容性方面,OOP 中的名义类型与结构类型有何不同?
- RQ2在名义类型语言中,继承在多大程度上可被形式化地等同于子类型?
- RQ3在类型系统中,哪些形式化特征使名义性区别于结构性?
- RQ4代码示例如何体现名义类型与结构类型在实际中的后果差异?
- RQ5支持子类型等同于继承在名义系统中有效的基础性原则是什么?
主要发现
- NOOP 模型成功形式化了名义类型 OOP 语言中继承与子类型的等同性。
- 名义类型依赖于显式类型名称与声明,从而与基于结构的类型兼容性相区别。
- 结构子类型允许仅基于类型结构的兼容性,而独立于名称或声明。
- 该模型确认,在名义类型系统中,子类型关系有效建立在继承关系之上。
- 附录中的代码示例表明,名义类型比结构类型施加了更严格的类型兼容性。
- 在 OOP 类型系统设计中,名义类型与结构类型的区分在概念和实践上均具有重要意义。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。