C++ Logo

SG20

Advanced search

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


Hi,

for years, I have significant problems to teach the range-based for
loop, because of the bug that it has undefined behavior when iterating
over a reference to a temporary.
Thus, I
- either have to tell beginners significant constraints in using it
- or have to teach all the details why it is broken
  including references, lifetime extension, universal references

Attached is a draft paper to fix the problem.
I welcome all feedback and if you want to be a co-author
(the more support the paper has the better).

Please also tell me if you have yourself significant teaching problems
there or interesting war stories about the problem.
There is a surprising number of people who thinks this is not a problem
at all.

May be SG20 can support the paper as a whole,
because IMO we really have to heal C++ to make it teachable again.

Best
  Nico

Note: So far I was not a member of this email list;
so forgive me if this was discussed before.

-- 
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