Changeset 4904b05 for doc


Ignore:
Timestamp:
Dec 23, 2025, 8:56:16 AM (3 days ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Parents:
80e83b6c
Message:

fix wording issues in last proofread of array chapter

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/mike_brooks_MMath/array.tex

    r80e83b6c r4904b05  
    17821782m@[0][1]@ = 3;   // subscript
    17831783\end{cfa}
    1784 The alternative \CFA syntax is a comma separated list.
     1784The alternative \CFA syntax is a comma separated list:
    17851785\begin{cfa}
    17861786int m@[2, 3]@;   // dimension
     
    17881788\end{cfa}
    17891789which should be intuitive to C programmers and is used in mathematics $M_{i,j}$ and other programing languages, \eg PL/I, Fortran.
    1790 With respect to the dimension expressions, C only allows an assignment expression.
     1790With respect to the dimension expressions, C only allows an assignment expression, not a comma expression.
    17911791\begin{cfa}
    17921792        a[i, j];
    17931793test.c:3:16: error: expected ']' before ',' token
    17941794\end{cfa}
    1795 However, there is an ambiguity for a single dimension array, where the syntax for old and new arrays are the same.
     1795However, there is an ambiguity for a single dimension array, where the syntax for old and new arrays are the same, @int ar[10]@.
    17961796The solution is to use a terminating comma to denote a \CFA-style single-dimension array.
    17971797\begin{cfa}
    1798 int m[2$\Huge\color{red},$];  // single dimension
     1798int ar[2$\Huge\color{red},$];  // single dimension new array
    17991799\end{cfa}
    18001800This syntactic form is also used for the (rare) singleton tuple @[y@{\Large\color{red},}@]@.
     
    18041804With respect to the subscript expression, the comma expression is allowed.
    18051805However, a comma expression in this context is rare, and is most commonly a (silent) mistake: subscripting a matrix with @m[i, j]@ instead of @m[i][j]@ selects the @j@th row not the @i, j@ element.
    1806 Finally, it is possible to write @m[(i, j)]@ in the new syntax to achieve the equivalent of the old @m[i, j]@.
     1806It is still possible to write @m[(i, j)]@ in the new syntax to achieve the equivalent of the old @m[i, j]@.
     1807Internally, the compiler must de-sugar @[i, j, k]@ into @[i][j][k]@ to match with three calls to subscript operators.
    18071808Note, there is no ambiguity for subscripting a single dimensional array, as the subscript operator selects the correct form from the array type.
    1808 Currently, @array@ supports the old amd new subscript syntax \see{\VRef{f:ovhd-treat-src}}, including combinations of new and old, @arr[1, 2][3]@.
    1809 Finally, the new syntax is trivially lowered to C-style dimension and subscripting.
     1809Currently, @array@ supports the old and new subscript syntax \see{\VRef[Figure]{f:ovhd-treat-src}}, including combinations of new and old, @arr[1, 2][3]@.
     1810The new subscript syntax can be extended to C arrays for uniformity, but requires the non-compatible removal of the (rare) comma-expression as a subscript.
    18101811
    18111812
Note: See TracChangeset for help on using the changeset viewer.