Date: Thu, 27 Jan 2022 14:10:37 +0000
On , 2022Jan27, at 07:42, Peter Sommerlad (C++) <peter.cpp_at_[hidden]<mailto:peter.cpp_at_[hidden]>> wrote:
I teach to use those optionals as replacements for pointers and I introduce optional before pointers as a means to return from a potentially failing function.
Don’t get me wrong, I love std::optional. But
1. Either your students already need to be familiar with the “.value()” mechanism, which implies that they understand classes,
2. Or they need to internalize “*optionalresult” which looks like a dereference but isn’t, so that’s doubly confusing if they do come from a C background.
And all of this when you’re just starting to teach parameter passing, which is where I started the discussion….
I do teach optional, even in a beginning course, but several weeks after I’ve taught them parameter passing.
Victor.
Received on 2022-01-27 14:10:40