Eigenstate: myrddin-dev mailing list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Add documentation for tuple access expressions


Hi myrddin-dev,

I updated the language spec to mention the feature my previous patch
introduces.  I also fixed some cross-references en passant.

Happy hacking.

---
 doc/lang.txt | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/doc/lang.txt b/doc/lang.txt
index 459ac509..2f50eb1e 100644
--- a/doc/lang.txt
+++ b/doc/lang.txt
@@ -1139,6 +1139,7 @@ TABLE OF CONTENTS:
 
             Precedence 11:
                     x.name          Member lookup
+                    x.N             Tuple component access
                     x++             Postincrement
                     x--             Postdecremendoc/libstd/varargst
                     x#              Dereference
@@ -1246,10 +1247,10 @@ TABLE OF CONTENTS:
 
             Atomic expressions are the building blocks of expressions, and
             are either parenthesized expressions or directly represent
-            literals. Literals are covered in depth in section 4.2.
+            literals. Literals are covered in depth in section 5.1.
 
             An identifier specifies a variable, and are looked up via
-            the scoping rules specified in section 4.9.
+            the scoping rules specified in section 3.5.
 
             Gap expressions (`_`) represent an anonymous sink value. Anything
             can be assigned to a gap, and it may be used in pattern matching.
@@ -1632,7 +1633,20 @@ TABLE OF CONTENTS:
                 (expr : <seq>).len : @idx
                 :: integral @a, numeric @a
 
-        5.2.22: Index:
+        5.2.22: Tuple Component Access
+
+                expr.N
+
+            Tuple component access operates on tuples. N must be a natural
+            number (i.e., 0, 1, 2, ...) and the type of `expr` must be a tuple
+            type with at least `N+1` components. The result of the expression
+            is an lvalue of the type of the `N+1`th component.
+
+            Type:
+
+                (expr : (@a0, ..., @aN, ...)).N : @aN
+
+        5.2.23: Index:
 
                 expr[idx]
 
@@ -1649,7 +1663,7 @@ TABLE OF CONTENTS:
                 (expr : @a[:])[(idx : @idx)] : @a
                 :: integral, numeric @idx
 
-        5.2.23: Slice:
+        5.2.24: Slice:
 
                 expr[lo:hi], expr[:hi], expr[lo:], expr[:]
 
@@ -1671,7 +1685,7 @@ TABLE OF CONTENTS:
                 (expr : @#)[(lo : @lo) : (hi : @hi)] : @a[:]
                 :: integral, numeric @lo, integral, numeric @hi
 
-        5.2.24: Call:
+        5.2.25: Call:
 
                 expr()
                 expr(arg1, arg2)
-- 
2.18.0