You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Positional collections have two spellings for one meaning: xs[i] and xs.get(i); keep [i] #1239
Eric, 2026-09-20: "get(1) shouldn't even be the way to access it, it should be [1] not get(1) unless there's a really good reason to have two spellings."
Today (D27, spec §13.x, CLAUDE.md):xs[i] denotes the element place and xs.get(i) returns &T, read-only, panicking out of range. On a positional collection the two observe the same element with the same failure mode: one meaning, two spellings. The mission says a default or a second spelling never selects between meanings, and a spelling that adds nothing is ceremony.
What the references do. Rust has both, but they mean different things: v[i] panics, v.get(i) returns Option — a real reason to have two. Go, Swift, Zig, Mojo and Vale index with [i] only. With's .get(i) has no such second meaning (D27 reserves Option-returning get for keyed maps, where absence is normal).
Proposal.xs[i] is the one user-facing spelling on Vec, arrays and slices. .get(i) on positional collections is removed from the user surface (a trait method may keep a name for implementations, but user code never writes it). The cheat-sheet in CLAUDE.md/AGENTS.md already says line.split("\t")[1] (changed on the #962 fix branch).
Cost. The compiler, stdlib, tests and tools use .get(i) on Vec pervasively (the legacy get(x as i64) idiom). Retiring it is a mechanical rewrite (with -p / a Lexer-based tool), then a diagnostic on positional .get( naming [i].
Needs: Eric's ruling amending D27, and the exact spec words. Related: #962 (a view into a temporary — bites [1] and .get(1) alike; fix on branch reject-view-into-temporary).
Fixed on main by 9a73f74 (#1968): Sema refuses Vec.get naming xs[i] (D71, README v7.4); the c-facade renderer and derive(SoA) emitters updated; tools/migrate_vec_get.w rewrote 876 + 48 in-tree sites; two compile_errors fixtures pin the diagnostic. Battery green on stack #1972. Noted out of scope on the PR: SortedVec.get(index) in lib/std and the derive(SoA) row accessor still exist (the issue names Vec/arrays/slices).
Activity
A view into a statement temporary cannot be bound or returned (#962) (#…
Retire `xs.get(i)` on Vec: `xs[i]` is the one element spelling (D71, #…
examples/ecs: element access is spelled xs[i] (D71, #1239)
Fixtures the Vec.get sweep did not compile spell element access xs[i]…
ComptimeEval: xs[i] indexes a Vec[u8] the evaluator holds as bytes (D…
Revert "ComptimeEval: xs[i] indexes a Vec[u8] the evaluator holds as …
Fixtures the D71 sweep did not reach spell element access xs[i] (D71, #…
Retire `xs.get(i)` on Vec: `xs[i]` is the one element spelling (D71, #…
Fixtures the D71 sweep and the §18.1 fallout did not reach: 48 `xs[i]…
ehartford commentedon Oct 2, 2026
Fixed on main by 9a73f74 (#1968): Sema refuses
Vec.getnamingxs[i](D71, README v7.4); the c-facade renderer and derive(SoA) emitters updated; tools/migrate_vec_get.w rewrote 876 + 48 in-tree sites; two compile_errors fixtures pin the diagnostic. Battery green on stack #1972. Noted out of scope on the PR:SortedVec.get(index)in lib/std and the derive(SoA) row accessor still exist (the issue names Vec/arrays/slices).