Subject: Re: Constant initialization in C++20
From: Mark A. Gibbs (indi.in.the.wired_at_[hidden])
Date: 2019-06-20 16:19:44
On 2019-06-19 6:56 a.m., Christopher Di Bella wrote:
> I would encourage newer books and classes to introduce keywords as
> they become necessary. There's no need to spam students with a bunch
> of words that have no place in a relevant class. For example, I'd like
> to see reinterpret_cast, const_cast, and union no longer show up in
> introductory material. Not mentioning consteval and co there is also a
> good idea.
I agree with the sentiment, but it doesn't seem practical in reality.
When I teach beginners about what they can use as a legal identifier, I
simplify it to "use only letters, numbers, and underscores, don't start
with a number or underscore, oh, and don't use any of these", and then
show the list of keywords and other reserved words. (Granted, this does
lead some inquisitive people to ask "what does this do? what does that
do?". I'm forced to brush them off so I can move on by saying something
to the tune of "if you don't know what it does, you probably don't need
it" or "when you need it, then you'll know what it does"... but that's
something I have to do a lot when teaching C++ anyway.)
Are there any other options for telling beginners what they can use for
their variable/function/class/whatever names? Without showing them the
list of keywords, how would they know they can't name something "union"
or "register" or "default"?
SG20 list run by herb.sutter at gmail.com
Older Archives on Google Groups