Add pattern guard docs to language ref

This commit is contained in:
Brian Anderson 2011-10-31 15:37:40 -07:00
parent 93035722a4
commit 151aaf84ce

View File

@ -676,6 +676,7 @@ The keywords are:
@tab @code{fail}
@tab @code{ret}
@tab @code{be}
@item @code{when}
@end multitable
@node Ref.Lex.Res
@ -3361,6 +3362,18 @@ let message = alt x @{
@}
@end example
Finally, alt patterns can accept @emph{pattern guards} to further refine the
criteria for matching a case. Pattern guards appear after the pattern and
consist of a bool-typed expression following the @emph{when} keyword. A pattern
guard may refer to the variables bound within the pattern they follow.
@example
let message = alt maybe_digit @{
some(x) when x < 10 @{ process_digit(x) @}
some(x) @{ process_other(x) @}
@}
@end example
@node Ref.Expr.Alt.Type
@subsubsection Ref.Expr.Alt.Type