From 36355c00093f783c7c36467ca7df9ffcd52c55b1 Mon Sep 17 00:00:00 2001 From: Matt-- Date: Sat, 19 Apr 2014 20:36:40 +1200 Subject: [PATCH] Update types.tex Added to Tuples example,lines 306-309 Now shows a tuple being created, used as a parameter, deconstructed and returned as a new tuple. Recommend keeping the comment as the phrase does not come up anywhere in the doc. I had to google it, my google foo was good... This editing change was pretty easy to do, I'll send more your way as I find them. --- WhileyLanguageSpecification/src/types.tex | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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}.