Java 7 闭包语法

发布于 2024-09-05 07:58:14 字数 119 浏览 5 评论 0原文

我下载了最后一个 Java 版本 b96-Feature Complete 用于测试新的 JDK 功能 但我不知道使用哪种语法来测试闭包!

我可以测试一下吗?

哪种语法在最终版本中已获得批准?

I download the last Java build b96- Feature Complete for testing the new JDK features
but I can't figure out which syntax using for testing closures!

Can I test it?

Which syntax has been approved in the final release?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蝶舞 2024-09-12 07:58:14

我不能确定,但​​我认为这个语法:

  // function expressions
  #(int i, String s) {
    System.println.out(s);
    return i + s.length();
  }

  // function expressions
  #(int i, String s) (i + s.length())

  // function types
  #int(int, String)

将按照 http 完成://docs.google.com/Doc?id=ddhp95vd_0f7mcns

I can't be certain, but I think this syntax:

  // function expressions
  #(int i, String s) {
    System.println.out(s);
    return i + s.length();
  }

  // function expressions
  #(int i, String s) (i + s.length())

  // function types
  #int(int, String)

Is going to make it through as per http://docs.google.com/Doc?id=ddhp95vd_0f7mcns

初熏 2024-09-12 07:58:14

为了回答你的问题,最终的语法尚未获得批准,尽管 M8 被列为功能完整的里程碑,但它并不具备所有建议的功能。您可以在此处阅读有关当前形式的该功能的信息,但很多讨论是现在还在继续,还有很长的路要走。此外,一旦解决了更紧迫的问题,语法将被重新审视,并可能在以后进行更改(至少是一些更改)。

此外,project-lambda 代码正在主线的 fork 中进行处理JDK7(我相信),所以我认为它不会出现在您下载的版本中。

To answer your question, no final syntax has been approved and, despite M8 being listed as the feature-complete milestone, it doesn't have all the proposed features. You can read here about the feature in its current form, but much discussion is going on now and it has quite a ways to go. Additionally, the syntax is going to be revisited and likely changed (at least some) later, once more pressing issues are worked out.

Also, project-lambda code is being worked on in a fork of the main line JDK7 (I believe), so I don't think any of it would be in the build you downloaded.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文