feat(stdlib): format all value types and expose handle identity members

- Add read-only FunctionRef.module/name and PluginHandle.plugin/export
  members; PluginHandle.id stays private (ADR-0029).
- Extend stdlib/format.mq.md to Formula/Code/FunctionRef/PluginHandle/
  Memory/Resource/Unit, with UTF-8 byte length for Code.
- Fix two-digit ordered-list body indentation so arms 10+ stay inside their
  branch (they were previously top-level statements).
- Extend stdlib demo to Formula/Code/FunctionRef and assert all three
  io.写值/打印 pairs match byte-for-byte.
- Add runtime member observation test, ADR-0029, spec/status/changelog/evidence.

Gate: fmt, clippy -D warnings, 416 tests passed.
This commit is contained in:
cflmy committed 2026-11-20 21:57:04 +08:00
1 parent 1377af1601
commit e119727c5d
14 files changed
+334 -15

No files matched your search

+21 -1
View File
@@ -3,8 +3,22 @@ import:
io: "./io.mq.md"
---
## 演示函数
*1*
## main
### 公式
$$a = 1$$
### 代码
```text
print(1)
```
**列表 = ["文本", 2, 1.5, [3, true], {a: 1, b: "x"}, None]**
> io.写值(列表)
@@ -17,4 +31,10 @@ import:
> 打印(表格)
*[类型(列表), 类型(表格)]*
**特殊 = [ref("#公式"), ref("#代码"), ref("#演示函数")]**
> io.写值(特殊)
> 打印(特殊)
*None*
+62 -4
View File
@@ -1,10 +1,44 @@
## 字节长度
`(文本)`
**点 = text.codepoints(文本)**
**总字节 = 0**
**下标 = 0**
- `下标 < 长度(点)`
**码点 = 点[下标]**
1. `码点 < 128`
**总字节 = 总字节 + 1**
2. `码点 < 2048`
**总字节 = 总字节 + 2**
3. `码点 < 65536`
**总字节 = 总字节 + 3**
4. `true`
**总字节 = 总字节 + 4**
**下标 = 下标 + 1**
*总字节*
## 显示
`(值)`
按语言值语义格式化,用于与内置 `打印` 的输出对照。
当前只覆盖 Unit/None/Bool/Int/Float/Text/List/Map/Table;Formula/Code/
FunctionRef/PluginHandle 仍缺少公开观察接口。
覆盖 Unit/None/Bool/Int/Float/Text/List/Map/Table/Formula/Code/
FunctionRef/PluginHandle/Memory/Resource。
**类别 = 类型(值)**
@@ -32,9 +66,33 @@ FunctionRef/PluginHandle 仍缺少公开观察接口。
*表格显示(值)*
7. `true`
7. `类别 == "Formula"`
*文本(值)*
*"Formula(" + 转义文本(值.latex) + ")"*
8. `类别 == "Code"`
*"Code(" + 转义文本(值.language) + ", " + 文本(字节长度(值.source)) + " bytes)"*
9. `类别 == "FunctionRef"`
*"FunctionRef(" + 值.module + "::" + 值.name + ")"*
10. `类别 == "PluginHandle"`
*"PluginHandle(" + 值.plugin + "::" + 值.export + ")"*
11. `类别 == "Memory"`
*"Memory"*
12. `类别 == "Resource"`
*"Resource"*
13. `true`
*文本(值)*
## 列表显示
+1 -1
View File
@@ -1,5 +1,5 @@
{
"name": "marqdo-stdlib",
"version": "0.1.0",
"digest": "sha256:000f39b01b3a1a7a8c32fe13d82db7f361166d1d7e8564d124b558f9b56d4e48"
"digest": "sha256:9ff5342c3279f4e468129e575570befb19ea38e7dc59e1c46a35da3515480430"
}