docs: tuple syntax cutover — Tuple(...) type, .(...) value, channel-outside-Tuple failables

Rewrite specs.md tuple/failable/pack/UFCS/grammar sections to the new
syntax, update readme.md, and refresh stale tuple references in example
header comments. Also fixes two pre-existing doc inaccuracies surfaced in
review: drop the value-discarding `;` in the tuple-return examples, and
correct the §13 function-type grammar production (optional param list +
optional trailing `!` channel). Optional semantics unchanged.

current/CHECKPOINT-LANG.md logs the cutover.
This commit is contained in:
agra
2026-06-25 18:41:22 +03:00
parent 1dfc22794e
commit 40b5fb5f7e
17 changed files with 184 additions and 103 deletions

View File

@@ -1,6 +1,6 @@
// Compound type literals in expression position — `size_of` /
// `align_of` accept pointer (`*T`), optional (`?T`), array (`[N]T`),
// function (`(A) -> B`), and tuple (`(A, B)`) types directly. Also
// function (`(A) -> B`), and tuple (`Tuple(A, B)`) types directly. Also
// const-decl RHS aliases through the same forms (`Ptr :: *u8;` etc).
// Same shape as the existing `size_of(i32)` baseline path.
@@ -22,7 +22,7 @@ main :: () -> i32 {
// Function-type literal in expression position.
print("size_of((i32)->i32) = {}\n", size_of((i32) -> i32));
// Tuple literal reinterpreted as tuple type at the type-demanding site.
// Tuple type at the type-demanding site.
print("size_of((i32, i32)) = {}\n", size_of(Tuple(i32, i32)));
// Aliases.

View File

@@ -2,7 +2,7 @@
// - `t.0 = v` writes one element in place (was a known gap: the lvalue path
// looked the element up by name via getStructFields and left the pointee
// `.unresolved`; now it indexes the tuple positionally like the read path).
// - Named tuples `(x: T, y: U)` keep their field names through parsing and
// - Named tuples `Tuple(x: T, y: U)` keep their field names through parsing and
// type resolution, so `t.x` reads/writes by name (and `.0` by position).
#import "modules/std.sx";

View File

@@ -1,12 +1,12 @@
// Parenthesized type grouping: in type position `(T)` (single element, no
// trailing comma) is a GROUPING that resolves to the inner type — mirroring
// value position where `(expr)` groups and `(expr,)` is a 1-tuple. A 1-tuple
// type requires the trailing comma `(T,)`; `(A, B)` is a 2-tuple.
// Parenthesized type grouping: bare parens `(T)` are GROUPING ONLY (in every
// position) and resolve to the inner type. A tuple type is `Tuple(...)`:
// `Tuple(T)` is a 1-tuple, `Tuple(A, B)` a 2-tuple. Bare parens never form a
// tuple.
//
// This lets a closure/optional type be parenthesized for readability:
// [1](Closure(i64,i64) -> i64) // array of closures (grouped element type)
// ?(?i64) // nested optional
// without the parens silently turning it into a 1-tuple.
// without ambiguity — grouping is decoupled from the tuple grammar.
#import "modules/std.sx";
@@ -28,7 +28,7 @@ main :: () {
fns : [1](Closure(i64, i64) -> i64) = .[ add ];
print("{}\n", fns[0](3, 4)); // 7
// A 1-tuple type still requires the trailing comma.
// A 1-tuple type is `Tuple(i64)`.
one : Tuple(i64) = .(9);
print("{}\n", one.0); // 9