@@ -656,16 +656,16 @@ The keywords are:
656
656
@tab @code {str }
657
657
@tab @code {with }
658
658
@tab @code {fn }
659
- @item @code {iter }
660
- @tab @code {pure }
659
+ @item @code {pure }
661
660
@tab @code {obj }
662
661
@tab @code {resource }
663
662
@tab @code {if }
664
- @item @code {else }
665
- @tab @code {alt }
663
+ @tab @code {else }
664
+ @item @code {alt }
666
665
@tab @code {in }
667
666
@tab @code {do }
668
667
@tab @code {while }
668
+ @tab @code {for }
669
669
@item @code {break }
670
670
@tab @code {cont }
671
671
@tab @code {note }
@@ -674,10 +674,7 @@ The keywords are:
674
674
@item @code {check }
675
675
@tab @code {prove }
676
676
@tab @code {fail }
677
- @tab @code {for }
678
- @tab @code {each }
679
- @item @code {ret }
680
- @tab @code {put }
677
+ @tab @code {ret }
681
678
@tab @code {be }
682
679
@end multitable
683
680
@@ -1688,7 +1685,6 @@ context. There are no general parametric types.
1688
1685
* Ref.Item.Mod :: Items defining modules.
1689
1686
* Ref.Item.Fn :: Items defining functions.
1690
1687
* Ref.Item.Pred :: Items defining predicates for typestates.
1691
- * Ref.Item.Iter :: Items defining iterators.
1692
1688
* Ref.Item.Obj :: Items defining objects.
1693
1689
* Ref.Item.Type :: Items defining the types of values and slots.
1694
1690
* Ref.Item.Tag :: Items defining the constructors of a tag type.
@@ -1970,48 +1966,6 @@ argument @code{f} is a pure function. So, to use @code{foldl} in a pure list
1970
1966
length function that a predicate could then use, we must use an
1971
1967
@code {unchecked } block wrapped around the call to @code {pure_foldl } in the
1972
1968
definition of @code {pure_length }.
1973
-
1974
- @node Ref.Item.Iter
1975
- @subsection Ref.Item.Iter
1976
- @c * Ref.Item.Iter:: Items defining iterators.
1977
-
1978
- @cindex Iterators
1979
- @cindex Put expression
1980
- @cindex Put each expression
1981
- @cindex Foreach expression
1982
-
1983
- Iterators are function-like items that can @code {put } multiple values during
1984
- their execution before returning.
1985
-
1986
- Putting a value is similar to returning a value -- the argument to @code {put }
1987
- is copied into the caller's frame and control transfers back to the caller --
1988
- but the iterator frame is only @emph {suspended } during the put, and will be
1989
- @emph {resumed } at the point after the @code {put }, on the next iteration of
1990
- the caller's loop.
1991
-
1992
- The output type of an iterator is the type of value that the function will
1993
- @code {put }, before it eventually evaluates a @code {ret } or @code {be } expression
1994
- of type @code {() } and completes its execution.
1995
-
1996
- An iterator can be called only in the loop header of a matching @code {for
1997
- each } loop or as the argument in a @code {put each } expression.
1998
- @xref {Ref.Expr.Foreach }.
1999
-
2000
- An example of an iterator:
2001
- @example
2002
- iter range(lo: int, hi: int) -> int @{
2003
- let i: int = lo;
2004
- while (i < hi) @{
2005
- put i;
2006
- i = i + 1;
2007
- @}
2008
- @}
2009
-
2010
- let sum: int = 0;
2011
- for each x: int in range(0,100) @{
2012
- sum += x;
2013
- @}
2014
- @end example
2015
1969
2016
1970
2017
1971
@node Ref.Item.Obj
@@ -2165,7 +2119,6 @@ Rust; they cannot be used as user-defined identifiers in any context.
2165
2119
* Ref.Type.Vec :: Open products of homogeneous types.
2166
2120
* Ref.Type.Tag :: Disjoint unions of heterogeneous types.
2167
2121
* Ref.Type.Fn :: Subroutine types.
2168
- * Ref.Type.Iter :: Scoped coroutine types.
2169
2122
* Ref.Type.Obj :: Abstract types.
2170
2123
* Ref.Type.Constr :: Constrained types.
2171
2124
* Ref.Type.Type :: Types describing types.
@@ -2447,28 +2400,6 @@ let bo: binop = add;
2447
2400
x = bo(5,7);
2448
2401
@end example
2449
2402
2450
- @node Ref.Type.Iter
2451
- @subsection Ref.Type.Iter
2452
- @cindex Iterator types
2453
-
2454
- The iterator type-constructor @code {iter } forms new iterator types. An
2455
- iterator type consists a sequence of input slots, an optional set of input
2456
- constraints and an output slot. @xref {Ref.Item.Iter }.
2457
-
2458
- An example of an @code {iter } type:
2459
- @example
2460
- iter range(x: int, y: int) -> int @{
2461
- while (x < y) @{
2462
- put x;
2463
- x += 1;
2464
- @}
2465
- @}
2466
-
2467
- for each i: int in range(5,7) @{
2468
- @dots {};
2469
- @}
2470
- @end example
2471
-
2472
2403
@node Ref.Type.Obj
2473
2404
@subsection Ref.Type.Obj
2474
2405
@c * Ref.Type.Obj:: Object types.
@@ -2938,7 +2869,6 @@ effects of the expression's evaluation.
2938
2869
* Ref.Expr.Break :: Expression for terminating a loop.
2939
2870
* Ref.Expr.Cont :: Expression for terminating a single loop iteration.
2940
2871
* Ref.Expr.For :: Expression for looping over strings and vectors.
2941
- * Ref.Expr.Foreach :: Expression for looping via an iterator.
2942
2872
* Ref.Expr.If :: Expression for simple conditional branching.
2943
2873
* Ref.Expr.Alt :: Expression for complex conditional branching.
2944
2874
* Ref.Expr.Prove :: Expression for static assertion of typestate.
@@ -3197,8 +3127,8 @@ fn read_file_lines(path: str) -> [str] @{
3197
3127
note path;
3198
3128
let r: [str];
3199
3129
let f: file = open_read(path);
3200
- for each s: str in lines(f) @{
3201
- vec::append(r,s) ;
3130
+ lines(f) @{ |s|
3131
+ r += [s] ;
3202
3132
@}
3203
3133
ret r;
3204
3134
@}
@@ -3301,26 +3231,6 @@ for e: foo in v @{
3301
3231
@}
3302
3232
@end example
3303
3233
3304
- @node Ref.Expr.Foreach
3305
- @subsection Ref.Expr.Foreach
3306
- @c * Ref.Expr.Foreach:: Expression for general conditional looping.
3307
- @cindex Foreach expression
3308
- @cindex Loops
3309
- @cindex Control-flow
3310
-
3311
- An @dfn {foreach loop } is denoted by the @code {for each } keywords, and is
3312
- controlled by an iterator. The loop executes once for each value @code {put } by
3313
- the iterator. When the iterator returns or fails, the loop terminates.
3314
-
3315
- Example of a foreach loop:
3316
- @example
3317
- let txt: str;
3318
- let lines: [str];
3319
- for each s: str in str::split(txt, "\n") @{
3320
- vec::push(lines, s);
3321
- @}
3322
- @end example
3323
-
3324
3234
3325
3235
@node Ref.Expr.If
3326
3236
@subsection Ref.Expr.If
0 commit comments