For AI agents: the complete documentation index is available at /tc39-atlas/llms.txt, the full documentation bundle is available at /tc39-atlas/llms-full.txt, and this page is available as Markdown at /tc39-atlas/proposals/year/pending/proposal-generator-arrow-functions.md.
  • 简体中文
  • Generator arrow functions ?

    中文标题:生成器箭头函数

    提案概览
    提案速览

    该提案旨在为目前不支持的生成器箭头函数提供简洁语法。它讨论了几种语法选项,如 () =>* 和新的 generator 关键字。

    Note

    以下 README 来自上游仓库,其中的阶段或状态标注可能滞后;当前信息以提案概览为准。

    ECMAScript 提案:生成器箭头函数

    作者:Sergey Rubanov

    ** Champion **:Hemanth HM、Brendan Eich (?)

    阶段TC39 流程的第 1 阶段。

    动机

    迄今为止的经验是,人们喜爱箭头函数和生成器,并且希望有一个生成器箭头函数。 — Brendan Eich

    箭头函数生成器自 ES2015 起都已可用。人们经常希望使用生成器箭头函数,而这个提案(多年前已提出)应该能解决他们的需求。

    使用案例

    可能的解决方案

    未来语法的讨论:https://github.com/tc39/proposal-generator-arrow-functions/issues/2

    箭头函数语法

    // 不规则
    () =*> ...
    
    // 与常规生成器函数的顺序不同
    () =>* ...
    
    // 也是错误的顺序
    () *=> ...
    
    // ASI 危险
    *() => ...

    function 和箭头函数引入新的 generator 关键字

    generator function() {}
    const foo = async generator function() {};
    
    class Foo {
      x = 1
      // 不再有 ASI 危险!
      generator foo() {}
    }

    TC39 会议记录

    先前讨论

    实现

    • 暂无