4 ms·
`std::this_thread::yield` already existed at the time, and “yield” was presumed to also be a common identifier in financial and agricultural contexts. I’m neve
by layer8 4y ago
`std::this_thread::yield` already existed at the time, and “yield” was presumed to also be a common identifier in financial and agricultural contexts.
I’m nevertheless surprised that new noncontextual and previously-unreserved-identifier keywords were added at all. In earlier times, the approach would have been to use a reserved identifier like “_Yield” for the keyword, and to provide a standard opt-in header that would `#define yield _Yield`. Maybe they don’t want to add dependencies on the preprocessor anymore.
- Sharlin 4y agoI’m not sure C++ has ever used the `_Yield` hack, except for C compatibility? C on the other hand uses it all the time.
- layer8 4y agoIt could be that I'm remembering it from C.
- chippiewill 4y agoIt's super common in C because C doesn't have namespaces and templates which means stuff C++ implements as namespaced library classes C has to implement as language keywords. A good example is atomics. C++11 introduced `std::atomic`, C11 introduced the keyword `_Atomic`
- nickysielicki 4y agoSuch a weak argument, you can fix this in your entire code base with a single call to sed. There is no reason to introduce a language feature with some weird prefix instead of changing existing code and having them prefix their variable names.