C++ Logo


Advanced search

Re: SG20 Digest, Vol 37, Issue 5

From: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
Date: Tue, 2 May 2023 11:26:12 -0400
On Tue, May 2, 2023 at 10:10 AM Victor Eijkhout via SG20 <
sg20_at_[hidden]> wrote:

> >
> > Unfortunately, I'm not in a position to try out this approach on real
> > students. My experience is that namespaces are seen as mysterious and
> > scary, but I don't know if that would be so if they were used in simple
> > ways from day #1.
> On day 1 they are learning what a loop is. Day 2 a function, day 3
> objects, day 4 containers. Maybe on day 10 they write something that is
> even big enough for separate compilation. (Which brings up the question of
> headers, makefiles, build systems. Day 11?)
> Point being there are many things that I would like to do on day 1, but my
> students brain capacity is limited. Last semester I tried integrating unit
> testing in a beginners course. With mixed success. Namespaces? Unless I can
> come up with a convincing enough example why they need it I’m not teaching
> it.

Whereas I would say that CS students, at least, should be familiar with the
idea of hierarchical names through
- Web domain names (books.google.com is the `books` member of google.com,
which is the `google` member of com)
- Directory/subfolder structures (/~ajo/bin is the `bin` subdirectory of
`/~ajo`, which is the `~ajo` subdirectory of root)
- Chapter subheadings in books (section 1.1 is the first subsection of
Chapter 1)
- If they already know some programming, then: objects and structs
(car.wheels is the `wheels` member of the car)

With that attitude, a hierarchical (qualified) name like "std::string" is
simply the "string" that is a member of the "std" namespace. Its full name
is "std::string", and that's how we're always going to refer to it in this
course. Things that come from the standard library are *always* qualified
with "std"; if you see "std", then you know you can go look that thing up
on cppreference (or just google it, in general). Things that don't come
from the standard library — things I just made up for this class — will
*never* be prefixed by "std". If you have a question about something not in
"std", you'll have to ask around here, because you'll *know* it's not part
of the portable standard.

This matches what someone else said, about not teaching students to form
wrong expectations regarding `std::vector`. If I have to choose between a
new hire confusedly asking:
(1) "Hey, I'm not really comfortable with this `std::vector` thing. My
teacher always used `ppp::vector` instead. Do we have `ppp::vector` here?"
(2) "Hey, this code I wrote seems to be behaving wrong at runtime, with no
message or anything, almost like it's... wrapping the index, or giving me
back a dummy value, or something? Shouldn't it safely abort when the index
is out of bounds? Does our `std::vector` have a bug or something?"
I would *vastly prefer* to deal with question #1 than with question #2.

> PS does someone know how to properly reply to a msg in a digest?

I believe this is one of those cases where "if you have to ask, the answer
is no." I believe it's impossible through Gmail. If you can control your
email client's message headers, then I'm sure it's possible to do it the
greybeard way — just go look up the `Message-ID` of the original post you
want to respond to (e.g. in this case <
606f4a64-b4a2-41a6-77a0-bd4d3223da55_at_[hidden]>, which is *almost*
entirely visible if you look at the HTML comments inside
https://lists.isocpp.org/sg20/2023/05/0352.php — I guess our hypothetical
greybeard would also have to know Bjarne's email domain by heart), and
paste that Message-ID into the `In-Reply-To` header of your reply. Ta-da,
easy as pie. ;)


Received on 2023-05-02 15:26:26