Skip to content

Fix syntax errors in "alt" documentation #1045

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 18, 2011
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions doc/rust.texi
Original file line number Diff line number Diff line change
Expand Up @@ -2133,7 +2133,7 @@ tag list<T> @{
cons(T, @@list<T>);
@}

let a: list<int> = cons(7, cons(13, nil));
let a: list<int> = cons(7, @@cons(13, @@nil));
@end example


Expand Down Expand Up @@ -3353,26 +3353,25 @@ equal the type of the head expression.

To execute a pattern @code{alt} expression, first the head expression is
evaluated, then its value is sequentially compared to the patterns in the arms
until a match is found. The first arm with a matching @code{case} pattern is
chosen as the branch target of the @code{alt}, any variables bound by the
pattern are assigned to local slots in the arm's block, and control enters the
block.
until a match is found. The first arm with a matching pattern is chosen as the
branch target of the @code{alt}, any variables bound by the pattern are
assigned to local slots in the arm's block, and control enters the block.

An example of a pattern @code{alt} expression:

@example
type list<X> = tag(nil, cons(X, @@list<X>));
tag list<X> @{ nil; cons(X, @@list<X>); @}

let x: list<int> = cons(10, cons(11, nil));
let x: list<int> = cons(10, @@cons(11, @@nil));

alt x @{
case (cons(a, cons(b, _))) @{
cons(a, @@cons(b, _)) @{
process_pair(a,b);
@}
case (cons(v=10, _)) @{
process_ten(v);
cons(10, _) @{
process_ten();
@}
case (_) @{
_ @{
fail;
@}
@}
Expand Down