Files
marqdo/doc/design/collection-access-link.md
cflmyandCursor ac3f0633cd refactor(tests): prefer link-index in structure collection golds
Move collection-* structure fixtures to [key](base), and modernize
public/stdlib table/fs/time demos with bracket-marked library calls.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 13:03:03 +08:00

1.9 KiB
Raw Permalink Blame History

集合取元:GFM 链接形

状态 Active(运行时)
日期 2026-09-14
相关 tables-maps-footnotes.md · markdown-mapping-v0.3.md · code-as-docs-gaps.md

1. 决议

表达式取元的主语法为 Markdown 链接外形,与 foreach 同构:

角色 写法
取元(表达式) [键](集合)
遍历(语句) - [项](集合)(不变)
脚注取元(过渡) 集合[^键] 仍解析,新代码勿写

心智:方括号 = 取出的名字,圆括号 = 从哪取。

**价 = [拿铁](菜单)**
**价 = [`名`](菜单)**
**第一 = [1](篮子)**

- [行](今日订单)
  **名 = [品名](行)**

2. 细则

写法 语义
[拿铁](菜单) 静态键;菜单 为变量(粗体/斜体内)
[`名`](菜单) 动态键(求值 名 再作键)
[1](篮子) List 1-based 下标(同脚注约定)
[1]([苹果](货架)) 嵌套链式

与 - [项](集合) 消歧:仅 表达式位置 的 […](…) 为取元;- 行头仍为 foreach。

3. 迁移

`菜单`[^拿铁] / 菜单[^拿铁] → [拿铁](菜单)(基与键左右对调)。

区域 约定
新代码 / examples / public 只用链接形
tests/structure/footnote* · interp-footnote* 脚注兼容门禁(保留)
其余 structure / ext / lib 金样 已迁链接形

脚注路径保留至另行决定移除之日;Skill / 教程 / 新示例只用链接形。

4. 非目标

  • 点号 map 访问、在、箭头取元、(键)[集合]
  • 循环语法糖(← / in / 自然语言)

5. 修订历史

日期 说明
2026-09-14 初稿并落地主语法