本文介绍了Simula 67中的C#迭代器和暂停/恢复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 诸如Simula 67之类的语言包含协同程序的一般概念, 允许暂停执行某个方法而不回滚 堆栈然后再恢复它被暂停的地方相同。 C#迭代器似乎是这个常规暂停/恢复的特殊情况 概念。 收益率语句暂停执行当前方法 并调用MoveNext()恢复它。 我认为引入一般暂停/恢复概念会更清晰 到C#然后在这个基础之上实现C#迭代器。已经将C#迭代器添加到C#中的方式似乎有点临时性;它是一个非常具体和独特的功能,并不会自然地与其他语言混合使用 。 JiriLanguages such as Simula 67 contain a general concept of coroutines thatallow the execution of a method to be suspended without rolling back thestack and then later resumed at the same place as it has been suspended.The C# iterators seem to be a special case of this general suspend/resumeconcept. The "yield" statement suspends the execution of the current methodand calling MoveNext() resumes it.I think it would be cleaner to introduce the general suspend/resume conceptto C# and then implement C# iterators on top of this general foundation. Theway C# iterators have been added to C# seems to be somewhat ad hoc; it is avery specific and distinct functionality that does not naturally blend withthe rest of the language.Jiri推荐答案 参见C#2.0规范。See the C# 2.0 spec. 这篇关于Simula 67中的C#迭代器和暂停/恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-28 11:42