Files
marqdo/doc/design/collection-access-link.md
T
cflmyandCursor 4a1c9c48a2 feat(markup): prefer [key](collection) for map and list access
Add GFM link-shaped index as the primary get surface, keep footnote
index as transitional compatibility, and align the coffee example.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 10:44:18 +08:00

1.6 KiB
Raw 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. 迁移

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

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

4. 非目标

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

5. 修订历史

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