Skip to content
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

Add gen blocks and reserve keyword in Rust 2024 #3513

Merged
merged 45 commits into from
Apr 7, 2024

Commits on Oct 11, 2023

  1. WIP

    oli-obk committed Oct 11, 2023
    Configuration menu
    Copy the full SHA
    1cbbe3c View commit details
    Browse the repository at this point in the history
  2. iter -> gen

    oli-obk committed Oct 11, 2023
    Configuration menu
    Copy the full SHA
    6b3726e View commit details
    Browse the repository at this point in the history
  3. ? desugaring

    oli-obk committed Oct 11, 2023
    Configuration menu
    Copy the full SHA
    585afb9 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    c905ce0 View commit details
    Browse the repository at this point in the history

Commits on Oct 12, 2023

  1. Configuration menu
    Copy the full SHA
    e10c2a6 View commit details
    Browse the repository at this point in the history
  2. replace-all failure

    oli-obk committed Oct 12, 2023
    Configuration menu
    Copy the full SHA
    625826d View commit details
    Browse the repository at this point in the history
  3. Motivation and generators

    oli-obk committed Oct 12, 2023
    Configuration menu
    Copy the full SHA
    3f3799a View commit details
    Browse the repository at this point in the history
  4. Add implementation section

    oli-obk committed Oct 12, 2023
    Configuration menu
    Copy the full SHA
    4146a83 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    ca7bb01 View commit details
    Browse the repository at this point in the history
  6. Explain lack of fusing

    oli-obk committed Oct 12, 2023
    Configuration menu
    Copy the full SHA
    e07b766 View commit details
    Browse the repository at this point in the history
  7. Actually, the async gen troubles aren't anything beyond the `self-r…

    …eferential` `gen` block issues
    oli-obk committed Oct 12, 2023
    1 Configuration menu
    Copy the full SHA
    1bb969f View commit details
    Browse the repository at this point in the history
  8. feedback (#2)

    * minor typos
    
    * intro
    
    * motivation
    
    * guide
    
    * reference
    
    * implementation
    
    * alternates
    
    * rationale
    
    * future
    
    * whitespace
    shepmaster committed Oct 12, 2023
    Configuration menu
    Copy the full SHA
    7d06af4 View commit details
    Browse the repository at this point in the history

Commits on Oct 13, 2023

  1. Configuration menu
    Copy the full SHA
    08c07d2 View commit details
    Browse the repository at this point in the history
  2. Address some concerns

    oli-obk committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    d89eb26 View commit details
    Browse the repository at this point in the history
  3. No syntax, only semantics

    oli-obk committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    e06745e View commit details
    Browse the repository at this point in the history
  4. Iterator::size_hint

    oli-obk committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    09c3ff1 View commit details
    Browse the repository at this point in the history
  5. Update RFC PR id

    oli-obk committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    45ce4db View commit details
    Browse the repository at this point in the history

Commits on Oct 14, 2023

  1. Fix and improve capitalization and punctuation

    There were some places with erroneous or unclear punctuation and
    capitalization.  Let's fix those and make some related typographic
    and linguistic improvements.
    traviscross authored and oli-obk committed Oct 14, 2023
    Configuration menu
    Copy the full SHA
    e9bbc6e View commit details
    Browse the repository at this point in the history
  2. Fix links to the unresolved questions section

    We had said `[text][#foo]` when we had meant to say `[text][foo]`,
    leading to broken internal link elements when referencing the
    unresolved questions section.  Let's fix that.
    traviscross authored and oli-obk committed Oct 14, 2023
    Configuration menu
    Copy the full SHA
    118b777 View commit details
    Browse the repository at this point in the history
  3. Add section noting C# prior art

    The C# (CSharp) language has a `yield` statement.  Let's describe this
    in a new prior art section.
    
    (Thanks to @scottmcm for pointing this out.)
    traviscross authored and oli-obk committed Oct 14, 2023
    Configuration menu
    Copy the full SHA
    00335a2 View commit details
    Browse the repository at this point in the history
  4. Add example and mention of std::iter::from_fn

    In the motivation, we enumerate some ways that people can create an
    iterator.  One way we didn't demonstrate was the use of
    `std::iter::from_fn`.  Let's do that, and let's add a mention of this
    in the section about the ever-present option of doing nothing.
    
    (Thanks to @estebank for pointing this out.)
    traviscross authored and oli-obk committed Oct 14, 2023
    Configuration menu
    Copy the full SHA
    94096d5 View commit details
    Browse the repository at this point in the history
  5. Clarify rules on the valid return type of a gen block

    We're specifying that `gen` blocks must diverge or return the unit
    type.  Let's articulate exactly what that means.
    
    (Thanks to @scottmcm for pointing this out.)
    traviscross authored and oli-obk committed Oct 14, 2023
    Configuration menu
    Copy the full SHA
    a8295c8 View commit details
    Browse the repository at this point in the history
  6. Clarify section on error handling

    The section on error handling discussed very specifically the behavior
    with `Option` and `Result` in a way that may have made the general
    case less clear.  E.g., it did not discuss the handling of
    `ControlFlow`, leaving unclear whether arbitrary types that implement
    the `Try` trait could be used.  It also did not discuss whether
    `From::from` was called as usual in case of short-circuiting.
    
    Let's simplify this section a bit by first discussing the desugaring,
    discussing the non-effect on the required type of trailing elements or
    arguments to `return` in the block, and discussing the effect on the
    type of the arguments required by `yield`.
    
    Notably, we won't discuss here the details of how `None` is returned
    to end iteration.  This behavior is the same as when `?` is not used,
    and the desugaring we describe fills in all of the needed details.
    
    (Thanks to @scottmcm for pointing out the ambiguous nature of this
    section.)
    traviscross authored and oli-obk committed Oct 14, 2023
    Configuration menu
    Copy the full SHA
    e5c803c View commit details
    Browse the repository at this point in the history

Commits on Oct 17, 2023

  1. Add more full history of generators in prior art

    Generators, iterators, and the `yield` keyword have a long history in
    the programming language literature.  Let's describe some of this
    history in the prior art section and add more examples of languages
    with these features.
    traviscross authored and oli-obk committed Oct 17, 2023
    Configuration menu
    Copy the full SHA
    b949fec View commit details
    Browse the repository at this point in the history

Commits on Oct 18, 2023

  1. Switch back to using gen keyword throughout RFC

    In the 2023-10-18 T-lang triage meeting, the team decided that this
    RFC should settle of the question of the keyword.  Consequently, let's
    commit to the `gen` keyword and use it throughout the document rather
    than using an attribute placeholder.
    traviscross committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    c982935 View commit details
    Browse the repository at this point in the history
  2. Remove language about an experiment

    Some of the language in this RFC implied that this is an experiment
    and that another RFC would be required.  This isn't how we want to
    frame things.  Another RFC could always be required, but it's also
    possible that stabilization could occur on the basis of this RFC.
    
    This is a normal RFC.  Let's remove all language about this being an
    experiment.
    traviscross committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    ffcf881 View commit details
    Browse the repository at this point in the history

Commits on Feb 29, 2024

  1. Address T-lang feedback

    oli-obk committed Feb 29, 2024
    Configuration menu
    Copy the full SHA
    b524348 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    349c517 View commit details
    Browse the repository at this point in the history

Commits on Mar 13, 2024

  1. Make self-referential gen blocks an open question

    We had listed self-referential `gen` blocks as a future possibility,
    but in discussion with T-lang, it's become clear that this should
    instead be listed as an open question, so let's do that.
    traviscross committed Mar 13, 2024
    Configuration menu
    Copy the full SHA
    b836635 View commit details
    Browse the repository at this point in the history

Commits on Mar 14, 2024

  1. Adjust for Generator -> Coroutine rename

    For many years, we had a trait in nightly Rust called `Generator`.
    We've now renamed this to `Coroutine`, but this RFC still referred to
    it as `Generator`.  Let's use the new name and make a note of the old
    one.
    traviscross committed Mar 14, 2024
    Configuration menu
    Copy the full SHA
    6478947 View commit details
    Browse the repository at this point in the history

Commits on Mar 15, 2024

  1. Add unresolved question about implemented traits

    To give us better options for supporting self-referential generators
    we may not want the type returned by `gen` blocks to implement
    `Iterator` directly.  Let's call this out as an open question and
    weaken claims throughout the document related to this.
    traviscross committed Mar 15, 2024
    Configuration menu
    Copy the full SHA
    a2bf473 View commit details
    Browse the repository at this point in the history
  2. Fix k#gen

    The language about how to refer to the `gen` keyword in older editions
    was changed in a recent commit from `k#gen` to `r#gen`.  This was
    probably a search/replace error.  Let's fix that.
    traviscross committed Mar 15, 2024
    Configuration menu
    Copy the full SHA
    caf93ba View commit details
    Browse the repository at this point in the history
  3. Fix where we fixed k#gen

    We meant to change `r#gen` to `k#gen` on one line to fix an apparent
    earlier search/replace error, and we erroneously changed it on a
    different line.  Let's fix the correct line and fix the mistaken fix.
    traviscross committed Mar 15, 2024
    Configuration menu
    Copy the full SHA
    8846955 View commit details
    Browse the repository at this point in the history

Commits on Mar 27, 2024

  1. Add tracking issue for RFC 3513

    We had already opened a tracking issue for this work, so let's fill
    that in here.
    traviscross committed Mar 27, 2024
    Configuration menu
    Copy the full SHA
    32ffb27 View commit details
    Browse the repository at this point in the history
  2. Rename file for RFC 3513

    In addition to giving the file the correct number, let's call this
    `gen-blocks` rather than `gen-fn` since we removed `gen fn` from the
    main body of this RFC.
    traviscross committed Mar 27, 2024
    Configuration menu
    Copy the full SHA
    3f0159d View commit details
    Browse the repository at this point in the history
  3. Update feature name to gen_blocks

    The feature name in the draft was a placeholder.  Let's update this to
    the actual feature name now in use.
    traviscross committed Mar 27, 2024
    Configuration menu
    Copy the full SHA
    787e0e9 View commit details
    Browse the repository at this point in the history
  4. Unwrap lines

    We had a mix between hard wrapped lines of various widths and
    unwrapped lines.  Let's unwrap all lines.
    traviscross committed Mar 27, 2024
    Configuration menu
    Copy the full SHA
    ad74905 View commit details
    Browse the repository at this point in the history
  5. Add future possibility of implementing FusedIterator

    The main body of the RFC discusses how we might implement
    `FusedIterator` for the iterators produced by `gen` blocks, but this
    was not listed as a future possibility.  Let's do that.
    traviscross committed Mar 27, 2024
    Configuration menu
    Copy the full SHA
    f6cd712 View commit details
    Browse the repository at this point in the history
  6. Remove incorrect statement about pinning

    There was a statement in the draft about, as a downside, something
    needing to be pinned for the entire iteration rather than just for
    each call to `next`.  But, of course, under the pinning guarantees,
    these are equivalent.  Once something is pinned, unless it is `Unpin`,
    it must be treated as pinned until it is destructed.  Let's remove
    this statement.
    traviscross committed Mar 27, 2024
    Configuration menu
    Copy the full SHA
    4bf6106 View commit details
    Browse the repository at this point in the history

Commits on Mar 28, 2024

  1. Add open question about Rust 2015 and Rust 2018

    In RFC 3101 we reserved in Rust 2021 prefixed identifiers such as
    `prefix#ident`.  For this reason, we can make `gen` blocks available
    in Rust 2021 using `k#gen` as was anticipated in the (currently
    pending) RFC 3098.
    
    It's less clear what to do about Rust 2015 and Rust 2018, however, so
    let's mark this as an open question.
    
    (Thanks to tmandry for raising this point.)
    traviscross committed Mar 28, 2024
    Configuration menu
    Copy the full SHA
    59be7f9 View commit details
    Browse the repository at this point in the history

Commits on Mar 29, 2024

  1. Do a round of copyediting

    We had been meaning to do some final copyediting prior to this RFC
    being merged, so let's do that.  In addition to making the text a bit
    more regular and precise, fixing some minor errors, removing outdated
    information, and adding references between sections, we've tried to
    "tighten it up" a bit where possible.  We've been careful to not
    change anything of semantic significance or otherwise of significance
    to the consensus.
    traviscross committed Mar 29, 2024
    Configuration menu
    Copy the full SHA
    31c7b28 View commit details
    Browse the repository at this point in the history
  2. Add Koka example to prior art

    The Koka language provides an interesting alternative data point for
    how generators and other powerful control flow constructs could work
    in a typed language such as Rust.  Let's include an example in the
    prior art section.
    
    (Thanks to zesterer for asking for this.)
    traviscross committed Mar 29, 2024
    Configuration menu
    Copy the full SHA
    7eacd06 View commit details
    Browse the repository at this point in the history
  3. Add Rust example to prior art

    Using the no-op `Waker`, we can express generators and coroutines in
    Rust.  Let's close our list of prior art examples with that.
    traviscross committed Mar 29, 2024
    Configuration menu
    Copy the full SHA
    a021905 View commit details
    Browse the repository at this point in the history
  4. Add note about return yield EXPR

    Under this RFC, it's possible to yield one last value concisely with
    `return yield EXPR`.  Let's make a note of that.
    
    (Thanks to Nemo157 for pointing this out and to pnkfelix for
    suggesting that this be noted in the RFC.)
    traviscross committed Mar 29, 2024
    Configuration menu
    Copy the full SHA
    354abf6 View commit details
    Browse the repository at this point in the history

Commits on Mar 30, 2024

  1. Use RLE as a stronger motivating example

    The motivating example we had given for `gen` blocks admitted too easy
    an implementation with existing stable iterator combinators.  Let's
    make the example more *motivating* by showing a simple algorithm,
    run-length encoding, that's more difficult to implement in other ways.
    
    (Thanks to Ralf Jung for pointing out the need for a better example.)
    traviscross committed Mar 30, 2024
    Configuration menu
    Copy the full SHA
    22f7267 View commit details
    Browse the repository at this point in the history