* Chris ( Val ):
> * Alf P. Steinbach:
> >
> > <url: http://home.no.net/dubjai/win32cpptut/special/pointers/preview/pointers_01__alpha.doc.pdf>.
> >
> > What do you think?
>
> I am very busy at the moment, but I had a very, very brief look,
> and a few things caught my eye, and that was to do with wording.
>
> I will look at the rest when I get a chance.
> Btw, it's just an opinion, so don't get too heated over it 
>
> 1 Pointers:
> A pointer is a value that identifies where some object or
> function is located in the computer's memory.
>
> // I would have said something along the lines of:
> * A pointer is a special type of variable that stores an address.
>
> * The address stored in the pointer is an integral value, which
> points to a location in the computer's memory.
>
> * Just like an address that identifies where a house is located
> on your street, the pointer address in turn identifies exactly
> where in memory an object of a given type can be located.
Well, I basically like your idea of pointing out (!) that a pointer is
effectively integral: you can increment and decrement pointers, and
there are no pointer values in between the values so generated (although
for some pointers these operations give undefined behavior).
There are however two reasons why I think it would not be a good idea to
mention that. First and foremost, the standard reserves the term
"integral type" to mean bool, char, wchar_t, and the signed and unsigned
integer types (the term integral type is defined in paragraph 3.9.1/7),
i.e.,
a pointer type is _not_ integral
in the standard's definition of the term. Second reason, I'd rather not
get into a discussion of raw arrays at this point, both because there's
so much said about that topic, and because the beginner is much better
served by using e.g. std::vector and std::string instead.
Regarding "special" and "variable": nope, a pointer is neither special
nor necessarily a variable. We often say that e.g. a function returns a
pointer to such and such. The function does not return a variable.
Regarding "an object": nope, a pointer does not necessarily point to an
object.
Actually I took pains to explain that last in detail, most of the ways
that a valid C++ pointer need _not_ point to an object. But then I
goofed on the introductory sentence! So thanks also for focusing on
that sentence. But how should it be rephrased? Perhaps put in the word
"basically" or some such, in parenthesis?
> 1.1 Introduction to the basics.
>
> // Remove this line or re-phrase it (covered in the text above):
> A pointer that tells where an object o is located is said to point to
> o.
It defines the term "point to" (shown in bold green), not yet covered.
> // A few lines down we find:
> *p = 42; Assigning to the object a pointer points to.
> which doesn't change p, but the object that p points to.
>
> That's called dereferencing. (*)
>
> I think this (*) is a little misleading - Although the operation
> is called assignment, it is not clear what you are actually calling
> dereferencing. Even though you mention the dereferencing operator
> a few more lines down, it has not been made clear what the act of
> dereferencing actually means.
Thanks -- perhaps just replace "that" by "applying *"?
> AFAIU, dereferencing is the act of applying an operator to a pointer
> variable, to ultimately access the undelying value of the object being
> pointed to - I think this or similar explanation should be provided
> for the newbie.
>
> // <nit> In the following sentence you have:
> And to make p point to o you just apply the address operator, &, to o:
>
> In this particular context, I always new this operator to be called
> the "address of" operator, rather than just the "address operator".
Not sure.
> // For your question in the following, I would add (shown below):
> p = &o; // Set p to point to o.
> *p = 42; // Assign
> And, for example, does the order of the two commented statements
> matter?
>
> * Yes, it does matter, and that is where one advantage of
> initialisation can help, if appropriate:
>
> int* p( &o ); // no order to worry about
Here I think I'll leave it as-is. In order to present a clean example I
deliberately did not use initialization. The example as-is shows that a
pointer variable isn't necessarily initialized at the point of
declaration. Bringing in C++ direct initializer syntax would just
confuse things, I think. Better with a minimal, clean example.
I hold to that guideline throughout the tutorial and this document.
For example, from a "best possible C++" view most of the classes I
present would benefit greatly from using constructors, access specifiers
and so on. But that would not help get across the points I want to get
across, it would just add more extranous things to deal with for the
reader (who possibly hasn't yet been introduced to those features, and
anyway does not necessarily see what their usage is all about in any
particular example). Instead I've chosen to present the minimum number
of concepts at a time, with minimum extranous clutter.
> Sorry I could not look at more of your tutorial (for now), but I
> will when I get some more time.
>
> Hope my opinions were useful
Yes, they were. Thank you,
- Alf
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?