docs(roadmap): special-char names — v2 inner-scope item, review follow-ups
draft feat/special-char-names
docs(roadmap): special-char names — v2 inner-scope item, review follow-ups Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| Changeset | f13bbd34e45402cccb86cd55c894c018873ad2f2 |
|---|---|
| Author (claimed) | Timo Stolz <timo.stolz@gmail.com>, |
| Parents | c13d7034d433 |
| Children | |
| Pushlog | by timo via ssh |
modified ROADMAP.md +39 −3
| @@ -276,14 +276,20 @@ | ||
| 276 | 276 | first hit. The scan resumes *after* a fused name (`Date-Time - Date-Time2` |
| 277 | 277 | keeps the minus an operator — the TCK 0007 expectation) and *inside* the run |
| 278 | 278 | after a miss (`a-b-c` with only `b-c` bound parses as `a - b-c`). Multi-char |
| 279 | - operators (`..` `...` `**` `->`) are not name symbols. API: | |
| 279 | + operators (`..` `...` `**` `->`) are not name symbols. A run only *starts* in | |
| 280 | + a variable position: never at a path member (a word after an unfused `.` — | |
| 281 | + `x.y-z` stays `(x.y) - z` even when the root binds `y-z`) and never at a | |
| 282 | + structure keyword (`return`, `in`, `then`, `else`, `satisfies`, `and`, `or`, | |
| 283 | + `between` — `return -i` yields no candidate). API: | |
| 280 | 284 | `compile_with_probe` + probe-aware one-shot `evaluate` (the context is the |
| 281 | 285 | scope); `compile()` stays probe-free (byte-identical; all 3145 pre-existing |
| 282 | 286 | cases re-verified). Metadata: `CompiledExpr::has_name_runs()` (this parse |
| 283 | 287 | consulted the scope) and `name_run_candidates(expr)` (probe-free: every |
| 284 | 288 | fusable candidate of the text — the "could some scope change this parse" set). |
| 285 | 289 | - **Wrappers** — one-shot `evaluate`/`evaluate_strict` in py/wasm/lua build the |
| 286 | - context first and parse with it as the probe; the `compile`/`CompiledExpr` | |
| 290 | + context and the ambient `functions` registry first and parse with both as the | |
| 291 | + probe (`ScopeWithFunctions` — a call head resolves against the registry too, | |
| 292 | + so `my-fn(2)` reaches a hyphen-named host function); the `compile`/`CompiledExpr` | |
| 287 | 293 | classes stay probe-free (a compiled program pins no scope) and are documented |
| 288 | 294 | as such. |
| 289 | 295 | - **feel-pg** — the `fn_extra` parse cache is probe-free, so both SQL functions |
| @@ -307,7 +313,37 @@ | ||
| 307 | 313 | `a and b` / `for x in y` scope-dependent, disabling feel-pg's parse cache for |
| 308 | 314 | nearly every nontrivial expression; Tier 1/2 unconditional joins stay the |
| 309 | 315 | documented scope-blindness); `?`/non-XID name starts (`what if?`, rule 28 — the |
| 310 | -0083-feel-unicode bucket). | |
| 316 | +0083-feel-unicode bucket); names in inner scopes (see v2 below). | |
| 317 | + | |
| 318 | +### v2: names in inner scopes (open) | |
| 319 | + | |
| 320 | +The probe sees only the **root level**. A special-character key one level down | |
| 321 | +keeps its arithmetic reading — `applicant.first-name` parses as | |
| 322 | +`applicant.first - name`, `items[unit-price > 10]` compares `unit - price`. | |
| 323 | +For jsonb rows (feel-pg) and nested JSON in the wrappers this is likely the | |
| 324 | +most common real-world shape, ahead of root-level hyphen keys. Pinned by a | |
| 325 | +feel-core test; workaround today: `get value(applicant, "first-name")`. | |
| 326 | + | |
| 327 | +Planned shape (no grammar change, lexer + probe only): | |
| 328 | + | |
| 329 | +1. **Static path members** — when a member run follows a *static* path chain | |
| 330 | + from a root name (`applicant.`, `p.q.`), ask the probe | |
| 331 | + `contains_member(path, name)` (new `ScopeProbe` method, default `false` — | |
| 332 | + non-breaking), which navigates the context value. Candidates become | |
| 333 | + path-qualified (`(["applicant"], "first-name")`), so feel-pg's per-row | |
| 334 | + guard navigates the jsonb the same way. Open: a list-valued step | |
| 335 | + (`orders.unit-price` maps over a list) — "first element" vs "any element". | |
| 336 | + Dynamic bases (`f(x).a-b`, `(e).a-b`) stay arithmetic. | |
| 337 | +2. **Filter-element keys** — inside a filter bracket over a static path, the | |
| 338 | + element keys are in scope (`items[unit-price > 10]`, | |
| 339 | + `items[item.unit-price > 10]`). Needs filter-vs-list-literal bracket | |
| 340 | + tracking in the lexer (the `mark_reverse_open` value-position classifier | |
| 341 | + already has that information). Same list-element question as 1. | |
| 342 | + | |
| 343 | +Prerequisite worth doing first: a parse cache keyed by *which* candidates are | |
| 344 | +bound (the parse is a pure function of the text and that subset), so nested | |
| 345 | +candidates do not turn into per-row re-parses in feel-pg and `compile()` can | |
| 346 | +follow the same rules. | |
| 311 | 347 | |
| 312 | 348 | ### Test ingestion (measured reality, and the hand-written fixture) |
| 313 | 349 | |