From 3d80e28b90be83418beb3bc931140a273afdfc4c Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 7 May 2004 12:44:43 +0000 Subject: *** empty log message *** --- doc/reference/ReferencePart.tex | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'doc/reference') diff --git a/doc/reference/ReferencePart.tex b/doc/reference/ReferencePart.tex index ce9fdd298a..811fbe90a8 100644 --- a/doc/reference/ReferencePart.tex +++ b/doc/reference/ReferencePart.tex @@ -3485,7 +3485,8 @@ value (or sequence of values). The same variable name may not be bound more than once in a pattern. Pattern matching is always done in a context which supplies an -expected type of the pattern. We distinguish the following kinds of patterns. +expected type of the pattern. We distinguish the following kinds of +patterns. A {\em variable pattern} $x$ is a simple identifier which starts with a lower case letter. It matches any value, and binds the variable @@ -3756,6 +3757,12 @@ def length [a] (xs: List[a]) = xs match { } \end{lstlisting} +In an application of \code{match} such as the one above, the expected +type of all patterns is the type of the qualifier of \code{match}. +In the example above, the expected type of the patterns \code{Nil} and +\code{x :: xs1} would be \code{List[a]}, the type of \code{xs}. + + \chapter{Top-Level Definitions} \label{sec:topdefs} -- cgit v1.2.3