semantics_specification
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
semantics_specification [2012/02/23 13:22] – [Native function semantics] xjia | semantics_specification [2012/03/25 13:57] (current) – [Operator types] mhwang | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== General considerations ====== | ====== General considerations ====== | ||
+ | * continue和break必须在循环里(for或者while) | ||
+ | * '' | ||
+ | * 不需要检查函数所有control flow末端是否都有return语句 | ||
+ | |||
+ | ====== 类型匹配 ====== | ||
+ | * return的表达式类型与函数返回类型一致 | ||
+ | * if/ | ||
+ | * '' | ||
+ | |||
+ | ====== 命名空间 ====== | ||
+ | |||
* native函数、普通函数、record名字,都不能重名,他们之间也不能重名 | * native函数、普通函数、record名字,都不能重名,他们之间也不能重名 | ||
* record的fields也不能重名(但可以和record本身同名,或与其他函数同名) | * record的fields也不能重名(但可以和record本身同名,或与其他函数同名) | ||
* 函数内变量之间不能重名,与top level的native函数、普通函数、record名字也不能重名 | * 函数内变量之间不能重名,与top level的native函数、普通函数、record名字也不能重名 | ||
- | * continue和break必须在循环里(for或者while) | ||
- | * 函数所有control flow末端(主要是if)必须有return语句,且return的表达式类型与函数返回类型一致 | ||
- | * if/ | ||
====== Operator types ====== | ====== Operator types ====== | ||
Line 11: | Line 19: | ||
^ '','' | ^ '','' | ||
^ '' | ^ '' | ||
- | ^ '' | + | ^ '' |
- | ^ '' | + | ^ '' |
^ ::: | ::: | 字符串比较的是值而不是地址 | | ^ ::: | ::: | 字符串比较的是值而不是地址 | | ||
- | ^ ''<'', | + | ^ ''<'', |
^ ::: | ::: | 字符串按字典序比较 | | ^ ::: | ::: | 字符串按字典序比较 | | ||
^ '' | ^ '' | ||
- | ^ '' | + | ^ '' |
^ '' | ^ '' | ||
^ '' | ^ '' | ||
^ 加法类型表 ^^ Right-hand side |||| | ^ 加法类型表 ^^ Right-hand side |||| | ||
- | ^::: ^^ int ^ char ^ string ^ record | | + | ^::: ^^ int ^ char ^ string ^ record/ |
^ Left-hand side ^ int | int | int | string | (error) | | ^ Left-hand side ^ int | int | int | string | (error) | | ||
^ ::: ^ char | int | int | string | (error) | | ^ ::: ^ char | int | int | string | (error) | | ||
^ ::: ^ string | string | string | string | (error) | | ^ ::: ^ string | string | string | string | (error) | | ||
- | ^ ::: ^ record | (error) | (error) | (error) | (error) | | + | ^ ::: ^ record/ |
====== Native function semantics ====== | ====== Native function semantics ====== | ||
^ '' | ^ '' | ||
^ '' | ^ '' |
semantics_specification.1330003367.txt.gz · Last modified: 2012/02/23 13:22 by xjia