shithub: mc

Download patch

ref: 01d9c59aa0f27db7bd3b9b8c1978c9a65c5e60a0
parent: f4a43f90e3ffe1712aec13566e8ac545da4161c4
author: Quentin Carbonneaux <quentin@c9x.me>
date: Mon Jul 16 11:59:50 EDT 2018

Add documentation for tuple access expressions

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

--- a/doc/lang.txt
+++ b/doc/lang.txt
@@ -1149,6 +1149,7 @@
 
             Precedence 11:
                     x.name          Member lookup
+                    x.N             Tuple component access
                     x++             Postincrement
                     x--             Postdecremendoc/libstd/varargst
                     x#              Dereference
@@ -1256,10 +1257,10 @@
 
             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.
@@ -1642,8 +1643,21 @@
                 (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]
 
             The indexing operator operates on slices and arrays. The
@@ -1659,7 +1673,7 @@
                 (expr : @a[:])[(idx : @idx)] : @a
                 :: integral, numeric @idx
 
-        5.2.23: Slice:
+        5.2.24: Slice:
 
                 expr[lo:hi], expr[:hi], expr[lo:], expr[:]
 
@@ -1681,7 +1695,7 @@
                 (expr : @#)[(lo : @lo) : (hi : @hi)] : @a[:]
                 :: integral, numeric @lo, integral, numeric @hi
 
-        5.2.24: Call:
+        5.2.25: Call:
 
                 expr()
                 expr(arg1, arg2)