C++ Logo

SG20

Advanced search

Subject: Re: A draft paper to fix the range-based for loop to make it teachable
From: Nicolai Josuttis (nico_at_[hidden])
Date: 2020-11-10 09:53:14


Am 10.11.2020 um 15:53 schrieb Yehezkel Bernat:
>
>
> On Tue, Nov 10, 2020 at 4:38 PM Amir Kirsh via SG20
> <sg20_at_[hidden] <mailto:sg20_at_[hidden]>> wrote:
>
> For example: don't return a const reference to a parameter that you
> got as const ref. It might be a temporary (great example I send my
> students to is here
> <http://www.youtube.com/watch?v=lkgszkPnV8g&t=13m0s>).
>
>
> I don't think the standard library agrees. E.g.
> https://en.cppreference.com/w/cpp/algorithm/min
> <https://en.cppreference.com/w/cpp/algorithm/min>
> This is probably the responsibility of the caller to not hold things as
> references in such cases.
>
>  
>
> But fixing just the range-based-for may lead to even more confusion.
>
>
> I like this argument!
>
It should be not argument anymore.
I.E we definitely should NOT teach it with pseudo code but with a black
box like a function call.
Then we don't have to explain this anymore.

The problem right now is that we HAVE to show and explain the pseudo
code because to explain the problem.

-- 
Nicolai M. Josuttis
www.josuttis.de
+49 (0)531 / 129 88 86
+49 (0)700 / JOSUTTIS
Books:
 C++: http://cppstdlib.com, http://cppstd17.com,
      http://tmplbook.com, http://cppmove.com
 SOA: http://soa-in-practice.com

SG20 list run by sg20-owner@lists.isocpp.org

Older Archives on Google Groups