News for hackers. Stuff that matters.
Re:C++ Core Coroutines Proposal [pdf] by mschuetz on Friday September 21, 2018 @06:05AM (#18038514)
> That's just a C# idiom

Not just C#, Python and JS also have it already. And async-await is the first time ever where I've thought that yes, this is a good way to do single-threaded async (event-queue-ish) or even multi-threaded things.

> Check POCO.

Thanks for the hint, I will check it out.

> but somehow you're complaining that C++'s interfaces require programmers to specify where the collections should start and finnish.

Take a look at: http://www.modernescpp.com/index.php/higher-order-functions The c++ functions are unnecesarely verbose compared to other languages.

This

    transform(vec.begin(), vec.end(), vec.begin(),[](int i){
        return i*i;
    });
could be much more readable as

    vec.map([](int i){ 
        return i*i;
    });
Also makes for-of the better choice in my opinion because if you're going to write more code, I'd rather write code that is readable.
Re:C++ Core Coroutines Proposal [pdf] by hhmc on Friday September 21, 2018 @11:41AM (#18040480)
Those examples aren't really the same though. Transform is a free function which operates on anything that satisfies 'ForwardIterator', map would be a member function of the vector class.

Theoretically you could add helper functions to all suitable containers which calls through to transform (I think this is what you're suggesting). But it would feel very heavyweight and add a lot of cruft to the std library.

You could also add your own utlity free function similar to

  template<class T, class F>
  void mymap(T &t, const F &f){
      std::transform(t.begin(), t.end(), t.begin(), f);
  }
Re:C++ Core Coroutines Proposal [pdf] by geezerjay on Friday September 21, 2018 @02:58PM (#18041859)
> could be much more readable as vec.map([](int i){ return i*i; });

That, however, violates the separation of concerns principle by mangling together data structures and algorithms.

Re:C++ Core Coroutines Proposal [pdf] by __s on Friday September 21, 2018 @08:20AM (#18039140)
Rust is also getting async/await
Re:C++ Core Coroutines Proposal [pdf] by steveklabnik on Friday September 21, 2018 @09:01AM (#18039348)
Which de-sugars to generators, which is similar to, but different from, the various C++ coroutine proposals. I haven’t dug into this one yet though...

It’s going to be pretty important for us: http://aturon.github.io/2018/04/24/async-borrowing/

Re:C++ Core Coroutines Proposal [pdf] by BeeOnRope on Friday September 21, 2018 @12:24PM (#18040794)
What you want is ranges v3.
Re:C++ Core Coroutines Proposal [pdf] by aaaaaaaaaab on Friday September 21, 2018 @07:17AM (#18038827)
Re:C++ Core Coroutines Proposal [pdf] by Timmah on Friday September 21, 2018 @12:24PM (#18040796)
That only saves a few characters. And "map" is already a data type in C++. How are you going to explain to a student that ambiguity, that you can "map a vector, but oh yeah map is also this container type" ?

Conceptually, I hate the word "map" to describe a transform. What does a real-world, paper map do? It associates locations drawn on the paper with real-world, physical places. That doesn't have any commonality whatsoever to morphing a group of objects. The term is misused.

Re:C++ Core Coroutines Proposal [pdf] by mschuetz on Saturday September 22, 2018 @01:25PM (#18046892)
It removes enough characters to turn it from unreadable mess to legible code. Point is mainly to remove the 3 completely unnecessary parameters, doesn't matter if it's called transform or map.