全部书籍

专业

应用 关于 Coach 登录 开始阅读

书籍暂未推出简体中文版——当前显示英文版。

Computer Science · 术语表

什么是 Static semantics, type checking?

又称: static semantics · type checking

Definition 4.5 University Computer Science — Year 3 · 第 4 章 — Abstract Syntax and Semantic Analysis

The static semantics of a language is the set of rules a program must satisfy beyond its grammar, checked before it runs: every name declared, every operator applied to operands of the right types, every function returning on every path. Type checking is the part of it that gives every expression of a program a type and checks that each construct receives operands of the types it requires.

A typing derivation for one statement, with = x: int, y: int, limit: int. The leaves look names up in ; each line is one rule. An if without else has the same rule without B_2.
A typing derivation for one statement, with Γ=x:int,y:int,limit:int\Gamma = \mathtt{x}{:}\mathsf{int}, \mathtt{y}{:}\mathsf{int}, \mathtt{limit}{:}\mathsf{int}. The leaves look names up in Γ\Gamma; each line is one rule. An if without else has the same rule without B2B_2.
在原文中阅读 →