✨ feat(tsl-syntax-reference): harden retrieval contracts
Add stable section IDs, structural and routing regressions, quickstart consistency checks, and CI enforcement. BREAKING CHANGE: replace heading-derived Section IDs with explicit syntax-NN-NNN identifiers.
This commit is contained in:
@@ -4,10 +4,14 @@
|
||||
|
||||
## 本篇职责
|
||||
|
||||
<!-- section-id: syntax-04-001 -->
|
||||
|
||||
回答“普通变量怎样直接使用、`var` 在什么位置出现、常量必须怎样初始化、哪些名字一旦绑定就不能再赋值”。
|
||||
|
||||
## 核心规则
|
||||
|
||||
<!-- section-id: syntax-04-002 -->
|
||||
|
||||
- 默认变量模型是“直接赋值即得到变量”,不要求先写 `var`。
|
||||
- 例如:`a := 1; b := array(1, 2, 3);` 这种写法可直接编译。
|
||||
- `var name;` 只作为显式声明写法,不能当成默认必需步骤。
|
||||
@@ -26,6 +30,8 @@
|
||||
|
||||
## 可直接照写示例
|
||||
|
||||
<!-- section-id: syntax-04-003 -->
|
||||
|
||||
使用这些示例时遵守:
|
||||
|
||||
- 默认生成普通变量时直接用 `:=`;只有用户明确要求或 `{$explicit+}` 场景才复制 `var`。
|
||||
@@ -34,6 +40,8 @@
|
||||
|
||||
### 普通变量与显式声明
|
||||
|
||||
<!-- section-id: syntax-04-004 -->
|
||||
|
||||
<!-- tags: 怎么声明变量, 变量要不要先定义, 直接赋值, var 用不用写 -->
|
||||
|
||||
默认变量模型:
|
||||
@@ -82,6 +90,8 @@ writeLn(a);
|
||||
|
||||
### 常量初始化
|
||||
|
||||
<!-- section-id: syntax-04-005 -->
|
||||
|
||||
<!-- tags: 定义常量, 只读的值, 不能改的值, const 怎么写 -->
|
||||
|
||||
顶层最稳的常量写法:
|
||||
@@ -170,6 +180,8 @@ value := kMaxRetries;
|
||||
|
||||
### 多参数赋值
|
||||
|
||||
<!-- section-id: syntax-04-006 -->
|
||||
|
||||
<!-- tags: 一次赋多个变量, 解构赋值, 拆数组到变量, 同时取两个值 -->
|
||||
|
||||
多参数赋值:
|
||||
@@ -297,6 +309,8 @@ end;
|
||||
|
||||
## 默认生成模板
|
||||
|
||||
<!-- section-id: syntax-04-007 -->
|
||||
|
||||
普通变量和顶层常量的默认骨架如下:
|
||||
|
||||
代码块身份:可直接照写示例
|
||||
@@ -309,6 +323,8 @@ items := array(1, 2, 3);
|
||||
|
||||
## 禁止项
|
||||
|
||||
<!-- section-id: syntax-04-008 -->
|
||||
|
||||
- 以为普通变量必须先写 `var` 才能使用。
|
||||
- 把常量初始化写成普通变量赋值风格。
|
||||
- 以为 `const =` 顶层单独写一行就一定成立。
|
||||
|
||||
Reference in New Issue
Block a user