Iterators in VB.NET vNext, and limitations of iterators in C#

倖福魔咒の 提交于 2019-12-23 12:01:29

问题


I just saw on the Async CTP website that the next version of VB.NET will have iterators. I guess they included iterators because the rewriting process is similar to the one used for the new async/await feature.

But reading the document that explains the feature, I realized that VB.NET iterators will actually have features that are not available in C# today, namely:

  • iterator blocks in a try/catch block
  • anonymous iterator blocks

These were known limitations in C#. Is there any chance that these limitations will be removed in C# 5 ? If not, is there any reason why it can be done in VB.NET and not in C# ?


回答1:


Is there any chance that these limitations will be removed in C# 5 ?

There is a slim chance. I certainly wouldn't count on it. Those are "nice to have" features, not "must have" features, and when you have an enormous amount of work to do, the "nice to have" features sometimes fall off the schedule, as nice as they are.

If not, is there any reason why it can be done in VB.NET and not in C# ?

Any technical reason? No. There are engineering reasons of course.

Often it is the case that being the second team to implement a particular feature is beneficial. The implementors of a second implementation get to take advantage of the knowledge gained from the first attempt without taking on so large a research and development cost, while not incurring any maintenance or backwards compatibility taxes.

VB has the benefit of not having had this feature already and therefore has no existing body of millions of lines of user code that they need to be 100% backwards compatible with. That is a considerable cost burden removed. And they have a large database of bug reports, design notes, and so on, from eight years of having this feature in C#.



来源:https://stackoverflow.com/questions/4063275/iterators-in-vb-net-vnext-and-limitations-of-iterators-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!