谁能简单描述一下 3 个闭包提案和它们在 Java 中的当前状态之间的差异?
我正在阅读有关 Java 7 中将出现的闭包的内容。
我有点困惑,因为一方面有很多很好的文章描述了新的 java 闭包。但从另一方面来看,有 3 种不同的规格,其中一些文章已经过时了,因为描述的不是最新的提案。
因此,如果有人从一开始就跟踪 java 闭包的进展,那么请简要描述所有 3 个提案及其当前状态。
关于闭包,我想知道的另一件事是,是否只有一条开发线存在,或者正在开发不同的版本(例如,来自 Sun、来自 Google、来自 Apache 等的闭包)?
I'm reading about closures which are going to appear in Java 7.
And I'm a bit confused because from one hand there are lots of nice articles which describe new java closures. But from the other hand there were 3 different specs and some of the articles are simply outdated because describe not the latest proposal.
So, if anyone tracks the progress of java closures from the begining then please describe in general terms very shortly all 3 proposals and their current state.
One more thing I wonder about closures is if there only one development line exists or different versions are being developed (like, closures from Sun, from Google, from Apache etc)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我没记错的话,
CICE 只是一个语法糖,可以更轻松地以类似于闭包的方式创建匿名类。
BGGA 是一个非常强大的提案,它不仅允许真正的闭包,还允许使用语法来定义看起来像新语法元素的结构(又名 using(Closable){block})。
FCM 是一个附加提案,试图在两者之间达成妥协,具有完全封闭的提案,但具有更好的语法,并且没有 BGGA 的一些更具争议性的功能。
当前提案可以在 http://www.javac.info/closures-v06a.html 找到 和 http://www.javac.info/closures-v06b.html,其中 A 部分是简单的完整 cosure,B 部分是取自 BGGA 的一些更强大的功能。
If I recall correctly
CICE was simply a syntactical sugar to more easily create anonymous classes in a way that looked like a closure.
BGGA was a very powerful proposal that allowed not only true closures, but also syntax to define structures that looked like new syntax elements (aka using(Closable){block}).
FCM was an additional proposal that tried to be a compromise between the two, with a full closure proposal, but with better syntax and without some of the more controversial features of BGGA.
The current proposal can be found at http://www.javac.info/closures-v06a.html and http://www.javac.info/closures-v06b.html, where part A is the simple full cosures, and part B is some of the more powerful features taken from BGGA.
据我了解,Project Lambda,添加 lambda 的计划更改(其中一些是Java 语言的闭包(某些闭包是 lambda)将是旧提案的混合。目前有关该提案的最新信息是 0.1规范草案。要随时了解进展情况,您可以关注 Mark Reinhold 的更新。
From what I understand, Project Lambda, the planned changes to add lambdas (some of which are closures, and some closures are lambdas) to the Java language, will be a mix of the older proposals. The currently most recent information available on the proposal is the 0.1 draft of the specification. To stay informed on the progress you can follow Mark Reinhold's updates.