V2EX  ›  英汉词典
Enqueued related words: Nominal Typing, Type Compatibility

Structural Typing

Definition 定义

结构类型(structural typing):一种类型系统判定方式,类型是否兼容主要看它们的结构(如字段、方法的名称与类型)是否匹配,而不是看它们是否显式声明为同一“名义类型”(如同一个类/接口名)。常见于一些面向对象或函数式语言及其类型系统中。(也常与 nominal typing“名义类型”对比。)

Pronunciation 发音

/ˈstrʌktʃərəl ˈtaɪpɪŋ/

Examples 例句

A language with structural typing lets you use any object that has the required fields.
结构类型的语言允许你使用任何具备所需字段的对象。

In a structural type system, a value can satisfy an interface without explicitly declaring it, as long as its shape matches the interface’s methods and properties.
在结构类型系统中,只要一个值的“形状”(方法与属性)与接口要求一致,它就可以满足该接口,即使它没有显式声明实现该接口。

Etymology 词源

structural 来自拉丁语 structura(“建造、结构”),强调“构成方式/结构”。typing 源自 type(“类型、范式”),在计算机语境中指“类型判定/类型系统”。合起来表示“按结构来判断类型”的方法。

Related Words 相关词

Literary/Notable Works 文学/著作示例

  • TypeScript Handbook(TypeScript 官方手册):明确介绍 TypeScript 采用 structural type system(结构类型系统)。
  • Benjamin C. Pierce, Types and Programming Languages:讨论类型系统概念与类型等价/兼容等相关思想(常涉及结构性判定的语境)。
  • Robert Harper, Practical Foundations for Programming Languages:在类型理论框架下讨论类型、子类型与等价等概念(可与结构类型理解相衔接)。
  • Luca Cardelli & Peter Wegner, “On Understanding Types, Data Abstraction, and Polymorphism”(论文):讨论类型与抽象等经典主题,常被引用来理解结构性与名义性类型观念的差异。
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   734 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 15ms · UTC 22:17 · PVG 06:17 · LAX 14:17 · JFK 17:17
♥ Do have faith in what you're doing.