diff --git a/WhileyLanguageSpecification/src/types.tex b/WhileyLanguageSpecification/src/types.tex index a9a7af9..00c8b81 100644 --- a/WhileyLanguageSpecification/src/types.tex +++ b/WhileyLanguageSpecification/src/types.tex @@ -303,8 +303,10 @@ \section{Tuples} \paragraph{Example.} The following example illustrates several uses of tuples: \begin{lstlisting} -function swap(int x, int y) => (int,int): - return y,x +(int, int) x = (4, 5) +function swap((int,int) x) => (int,int): + int a, int b = x // tuple destructuring assignment + return b, a \end{lstlisting} This function accepts two integer parameters, and returns a tuple type containing two integers. The function simple reverses the order that the values occur in the tuple passed as a parameter. @@ -729,4 +731,4 @@ \subsection{Subtyping} \begin{definition}[Subtype Completeness] A subtype operator, ${\tt\le}$, is {\em complete} if, for any types ${\tt T_1}$ and ${\tt T_2}$, it holds that ${\tt \llbracket T_1\rrbracket\subseteq\llbracket T_2\rrbracket\Longrightarrow T_1\le T_2}$. \end{definition} -\noindent A subtype operator which exhibits both of these properties is said to be {\em sound} and {\em complete}. \ No newline at end of file +\noindent A subtype operator which exhibits both of these properties is said to be {\em sound} and {\em complete}.