🐛 fix(tsl-syntax-reference): close verified syntax gaps
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
- 完整 `unit` 形态可以包含 `interface`、`implementation`、`initialization`、`finalization`,并以 `end.` 结束。
|
||||
- `initialization` 在 `unit` 第一次被实际使用时触发,不是只因为顶层写了 `uses` 就立刻执行。
|
||||
- `finalization` 会在脚本结束前触发。
|
||||
- 直接写 `DemoUnit.Member` 时,可以读到 `interface` 和 `implementation` 里的常量、变量。
|
||||
- 跨版本安全边界只保证 `interface` 中声明的常量、变量和函数可由引用者访问;只在 `implementation` 中声明的成员按私有内容处理。
|
||||
- `findFunction("DemoUnit")` 拿到的是 `unit` 对象入口;本页只把它稳定暴露 `interface` 成员写成文档事实。
|
||||
- `DemoUnit.var_name := value` 这种限定赋值不作为可写事实;如果要改 `unit` 状态,应导出函数或方法来改。
|
||||
- `tslfilename()` 的参数规格使用 `tsl-api-reference` skill 按名查询;本页只保留它返回正在执行的 `.tsl` 主脚本完整路径这一行为事实。
|
||||
@@ -111,7 +111,7 @@ FINAL
|
||||
|
||||
<!-- tags: 读模块常量, 访问 unit 成员, 限定名读取 -->
|
||||
|
||||
直接限定读取:
|
||||
跨版本安全的限定读取:
|
||||
|
||||
代码块身份:配置片段 / 概念骨架
|
||||
|
||||
@@ -149,8 +149,6 @@ uses DemoUnit;
|
||||
|
||||
writeLn(DemoUnit.public_const);
|
||||
writeLn(DemoUnit.public_var);
|
||||
writeLn(DemoUnit.impl_const);
|
||||
writeLn(DemoUnit.impl_var);
|
||||
writeLn(PublicFunc());
|
||||
```
|
||||
|
||||
@@ -158,10 +156,10 @@ writeLn(PublicFunc());
|
||||
|
||||
- `DemoUnit.public_const` 输出 `1`。
|
||||
- `DemoUnit.public_var` 输出 `3`。
|
||||
- `DemoUnit.impl_const` 输出 `2`。
|
||||
- `DemoUnit.impl_var` 输出 `4`。
|
||||
- `PublicFunc()` 输出 `10`。
|
||||
- 本页文档边界是:实现段函数仍私有,但实现段常量和变量可以通过 `DemoUnit.Member` 直接读取。
|
||||
- 本页的跨版本文档边界是:外部只依赖 `interface` 引出的成员;实现段里的常量、变量和函数都视为私有。
|
||||
|
||||
部分新一代解释器允许用 `DemoUnit.impl_const` / `DemoUnit.impl_var` 限定读取实现段数据,但这与经典 `unit` 可见性规则冲突,不作为跨环境默认生成能力。若项目已经依赖该行为,必须先按目标解释器实测并记录版本。
|
||||
|
||||
实现段函数的外部调用反例:
|
||||
|
||||
@@ -491,7 +489,7 @@ writeLn(Hello());
|
||||
<!-- section-id: syntax-18-011 -->
|
||||
|
||||
- 把 `DemoUnit.var_name := value` 当成可用的限定赋值。
|
||||
- 以为 `implementation` 里的常量和变量一定都不能从 `DemoUnit.Member` 读到。
|
||||
- 默认从外部读取只在 `implementation` 中声明的成员;跨版本安全代码应通过 `interface` 导出。
|
||||
- 以为 `findFunction("DemoUnit")` 暴露的成员范围和 `DemoUnit.Member` 完全相同。
|
||||
- 把脚本内的 `namespace "..."` 当成和 `tsl.conf` 里的 `Namespace=...` 叠加,而不是覆盖。
|
||||
- 把 `-LIBPATH` 放在脚本文件名前面。
|
||||
|
||||
Reference in New Issue
Block a user