Why wasn't yield added to C++0x?

后端 未结 8 1655
谎友^
谎友^ 2020-12-13 18:51

I have been using yield in many of my Python programs, and it really clears up the code in many cases. I blogged about it and it is one of my site\'s popular pages.

相关标签:
8条回答
  • 2020-12-13 19:29

    there have been several implementation of coroutines as user-space libraries. However, and here is the deal, those implementations rely on non-standard details. For example, nowhere on the c++ standard is specified how stack frames are kept. Most implementations just copy the stack because that is how most c++ implementations work

    regarding standards, c++ could have helped coroutine support by improving the specification of stack frames.

    Actually 'adding' it to the language doesn't sound a good idea to me, because that would stick you with a 'good enough' implementation for most cases that is entirely compiler-dependent. For the cases where using a coroutine matters, this is not acceptable anyways

    0 讨论(0)
  • 2020-12-13 19:35

    In general, you can track what's going on by the committee papers, although it's better for keeping track rather than looking up a specific issue.

    One thing to remember about the C++ committee is that it is a volunteer committee, and can't accomplish everything it wants to. For example, there was no hash-type map in the original standard, because they couldn't manage to make it in time. It could be that there was nobody on the committee who cared enough about yield and what it does to make sure the work got done.

    The best way to find out would be to ask an active committee member.

    0 讨论(0)
提交回复
热议问题