Changeset 4d3666d


Ignore:
Timestamp:
Aug 25, 2022, 11:51:11 AM (2 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, ast-experimental, master, pthread-emulation
Children:
d2f09e4
Parents:
b59d6d1
Message:

fix spelling and wording

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/proposals/iterators.md

    rb59d6d1 r4d3666d  
    22=========
    33This is the proposal for adding iterators to Cforall and the standard
    4 libary. Iterators provide a common interface for sequences of values in
     4library. Iterators provide a common interface for sequences of values in
    55the language. Many inputs and outputs can be described in terms of sequences,
    66creating a common interface that can be used in many places.
     
    1515The operation is "get the next value in the sequence", but this actually has
    1616several parts, in that it has to check if there are move values, return the
    17 next one if there is, and update any internal information in the iterator.
     17next one if there is one, and update any internal information in the iterator.
    1818For example: `Maybe(Item) next(Iter &);`.
    1919
    2020Now, iterators can have other operations. Notably, they are often also
    21 iterables that return themselves. They can also have a veriaty of iterator
     21iterables that return themselves. They can also have a verity of iterator
    2222transformers built in.
    2323
     
    2525
    2626Anything that you can get an iterator from is called an iterable. There
    27 is an operation to get an iterator from an iterator.
     27is an operation to get an iterator from an iterable.
    2828
    2929Range For Loop
     
    3131One part of the language that could be reworked to make good use of this is
    3232for loops. In short, remove most of the special rules that can be done inside
    33 the identifer and make it a generic range for loop:
     33the identifier and make it a generic range for loop:
    3434
    3535    ```
     
    3939The common way to implement this is that expression produces an iterable.
    4040The for loop gets an iterator from the iterable (which is why iterators are
    41 often iterables, so they can be passed in with the same iterface) and stores
     41often iterables, so they can be passed in with the same interface) and stores
    4242it. Then, for each value in the iterator, the loop binds the value to the
    4343identifier and then executes the statement. The loop exits after every value
    44 has been used and the iterator is exausted.
     44has been used and the iterator is exhausted.
    4545
    4646For the chained for loop (`for (i; _: j; _)`) can still have its existing
    4747behaviour, advancing through each range in parallel and stopping as soon
    48 as the first one is exausted.
     48as the first one is exhausted.
    4949
    5050Ranges
     
    5454logically instead of by copy.
    5555
    56 The purpose of this container is to bridge the new iterator iterfaces with
     56The purpose of this container is to bridge the new iterator interfaces with
    5757the existing range syntax. The range syntax would become an operator that
    5858returns a range object, which can be used as any other type.
     
    9191pointers.
    9292
    93 Rust also has a imparative implementation of a functional style of iterators,
     93Rust also has a imperative implementation of a functional style of iterators,
    9494including a great number of standard transformers. Otherwise, it is very
    9595similar to Python.
Note: See TracChangeset for help on using the changeset viewer.