Date: Fri, 23 Aug 2019 17:00:14 -0400
I am not in favor of the status quo. I believe that C++ is broken,
probably beyond redemption, and I'm dubious that band-aid fixes
here and there are going to make things better.
You say when you look at `auto x = {1}`, the only logical explanation in
your mind is that the RHS is an initializer list but you have no intuition
for `auto x{1}`. But in the context of teaching C++, why would that be?
What is it about the presence or absence of the `=` that will speak to
the intuition of the student? Are students supposed to know about
initializer lists at all? Aren't they supposed to be behind-the scenes
magic that let you write intuitive initializers without thinking about how
they work?
Also, even without `auto` things are unteachably strange.
`vector<int>vi3{3};` gives me a vector containing a single 3.
`vector<string>vs3{3};` gives me a vector containing 3 empty strings.
`vector<int>vi0{0};` gives me a vector containing a single 0.
`vector<string>vs0{0};` has undefined behavior and usually crashes.
If I use `=` before the braces, the only thing that changes is that the
`vs3` line doesn't compile, with messages about vector's constructor
being explicit.
probably beyond redemption, and I'm dubious that band-aid fixes
here and there are going to make things better.
You say when you look at `auto x = {1}`, the only logical explanation in
your mind is that the RHS is an initializer list but you have no intuition
for `auto x{1}`. But in the context of teaching C++, why would that be?
What is it about the presence or absence of the `=` that will speak to
the intuition of the student? Are students supposed to know about
initializer lists at all? Aren't they supposed to be behind-the scenes
magic that let you write intuitive initializers without thinking about how
they work?
Also, even without `auto` things are unteachably strange.
`vector<int>vi3{3};` gives me a vector containing a single 3.
`vector<string>vs3{3};` gives me a vector containing 3 empty strings.
`vector<int>vi0{0};` gives me a vector containing a single 0.
`vector<string>vs0{0};` has undefined behavior and usually crashes.
If I use `=` before the braces, the only thing that changes is that the
`vs3` line doesn't compile, with messages about vector's constructor
being explicit.
Received on 2019-08-23 16:02:29