3 ms·
For all of the STL's power, and all the useful stuff in std::algorithm, it's still impossible to write something as elegant as a list comprehension in Python.
by blt 12y ago
For all of the STL's power, and all the useful stuff in std::algorithm, it's still impossible to write something as elegant as a list comprehension in Python. It's really exciting to see Eric's work taking us closer to this goal.
On the other hand, I always worry about all the magic implicit behavior in C++, both in old and new language features. We're writing in C++, we care about efficiency. Eric addresses this by requiring rvalue references in the container algorithms, but in general it's pretty easy to write code that does more work than you expected.
Since most undesired magic in C++ boils down to allocating heap memory unexpectedly, it would be cool to add syntax to could tell the compiler that a block is not allowed to allocate, like:
noalloc {
bigvec = std::move(bigvec) | cont::sort | cont::unique;
}