More support for Paul's array terminology

Discussion in 'C++' started by Michael Tsang, Jun 13, 2011.

  1. Alf P. Steinbach /Usenet wrote:

    > To be fair, it just occurred to me, as an example, that we do say "pointer
    > to array of pointers" and not "pointer to first element in an array of
    > pointers".
    >
    > And now I will probably have to kill this thread...
    >
    > Thanks to Ian Collins for the 'K' key tip for Thunderbird!
    >
    >
    > Cheers & hth.,
    >
    > - Alf
    >


    Are you saying that if x is a "pointer to array of pointer of T", then x is to
    be declared as:

    T *(*x)[5];

    ??
    Michael Tsang, Jun 13, 2011
    #1
    1. Advertising

  2. To be fair, it just occurred to me, as an example, that we do say "pointer to
    array of pointers" and not "pointer to first element in an array of pointers".

    And now I will probably have to kill this thread...

    Thanks to Ian Collins for the 'K' key tip for Thunderbird!


    Cheers & hth.,

    - Alf

    --
    blog at <url: http://alfps.wordpress.com>
    Alf P. Steinbach /Usenet, Jun 13, 2011
    #2
    1. Advertising

  3. Michael Tsang wrote:

    > Alf P. Steinbach /Usenet wrote:
    >
    >> To be fair, it just occurred to me, as an example, that we do say
    >> "pointer to array of pointers" and not "pointer to first element in an
    >> array of pointers".
    >>
    >> And now I will probably have to kill this thread...
    >>
    >> Thanks to Ian Collins for the 'K' key tip for Thunderbird!
    >>
    >>
    >> Cheers & hth.,
    >>
    >> - Alf
    >>

    >
    > Are you saying that if x is a "pointer to array of pointer of T", then x
    > is to be declared as:
    >
    > T *(*x)[5];
    >


    I think that's completely unreadable. I prefer to use alias templates for
    improved readability.

    template<typename T> using alias = T;
    alias<T*[5]> *x;
    Johannes Schaub (litb), Jun 13, 2011
    #3
  4. Michael Tsang

    gwowen Guest

    On Jun 13, 2:35 pm, "Alf P. Steinbach /Usenet" <alf.p.steinbach
    > wrote:
    > To be fair, it just occurred to me, as an example, that we do say "pointer to
    > array of pointers" and not "pointer to first element in an array of pointers".


    I don't know if anyone's ever suggested that's not a useful
    colloquialism (well, Leigh maybe, but I wouldn't know).
    gwowen, Jun 14, 2011
    #4
  5. Michael Tsang

    SG Guest

    On 13 Jun., 18:12, Johannes Schaub (litb) wrote:
    >
    > > T *(*x)[5];

    >
    > I think that's completely unreadable.
    > I prefer to use alias templates for improved readability.
    >
    > template<typename T> using alias = T;
    > alias<T*[5]> *x;


    Nice. I first thought, you're making a joke.

    I guess you can also declare functions like this

    alias<int(int,char*)> main;

    ;-)

    Cheers!
    SG
    SG, Jun 14, 2011
    #5
  6. On 6/14/2011 4:51 AM, SG wrote:
    > On 13 Jun., 18:12, Johannes Schaub (litb) wrote:
    >>
    >>> T *(*x)[5];

    >>
    >> I think that's completely unreadable.
    >> I prefer to use alias templates for improved readability.
    >>
    >> template<typename T> using alias = T;
    >> alias<T*[5]> *x;

    >
    > Nice. I first thought, you're making a joke.
    >
    > I guess you can also declare functions like this
    >
    > alias<int(int,char*)> main;


    I believe it ought to be

    alias<int(int,char**)> main;

    No?

    >
    > ;-)
    >
    > Cheers!
    > SG


    V
    --
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Jun 14, 2011
    #6
  7. Michael Tsang

    Paul Guest

    "Leigh Johnston" <> wrote in message
    news:p...
    > On 14/06/2011 08:19, gwowen wrote:
    >> On Jun 13, 2:35 pm, "Alf P. Steinbach /Usenet"<alf.p.steinbach
    >> > wrote:
    >>> To be fair, it just occurred to me, as an example, that we do say
    >>> "pointer to
    >>> array of pointers" and not "pointer to first element in an array of
    >>> pointers".

    >>
    >> I don't know if anyone's ever suggested that's not a useful
    >> colloquialism (well, Leigh maybe, but I wouldn't know).

    >
    > I made it clear on multiple occasions that the phrases "pointer to" and
    > "points to" can mean different things *if* we are being less formal (i.e.
    > not technically accurate):
    >

    It is perfectly acceptable to say it's a "pointer to.." . and to mean
    exactly the same as "it points to", because its very slight difference is
    only grammatical.

    If you want to say it's "type is pointer to.." then say that , it's
    inaccurate to leave out the 'type' word and assume your definition of the
    term "a pointer to" always can mean is "type pointer to" because your
    interpretation is a sloppy interpretation and simply a shorthand version of
    saying "it's type is pointer to".

    > int* p = new int[42];
    >
    > 1) 'p' is a pointer to an 'int';
    > 2) 'p' is not a pointer to an array of 'int';
    > 3) 'p' points to the first element of an array of 'int'
    > 4) 'p' points to an array of 'int'.
    >
    > (1) and (2) both describe the *type* of 'p' whilst (3) and (4) describe
    > runtime properties (i.e. the *objects* pointed to).
    >
    > If we are being more formal (i.e. technically accurate) then I would
    > consider (4) to be incorrect.
    >


    This is a pointer to the right hand side of the page... ---->
    It's "pointer to" the rhs of the page because it "points to" the rhs of the
    page.
    Both terms mean exactly the same thing but are used in a slightly different
    grammatical context.

    You are obviously very confused by the english language. Go away and try to
    find some latin quotation so you can come back and disprove me.
    Paul, Jun 14, 2011
    #7
  8. On Jun 14, 1:42 pm, Leigh Johnston <> wrote:
    > On 14/06/2011 08:19, gwowen wrote:
    >
    > > On Jun 13, 2:35 pm, "Alf P. Steinbach /Usenet"<alf.p.steinbach
    > > >  wrote:
    > >> To be fair, it just occurred to me, as an example, that we do say "pointer to
    > >> array of pointers" and not "pointer to first element in an array of pointers".

    >
    > > I don't know if anyone's ever suggested that's not a useful
    > > colloquialism (well, Leigh maybe, but I wouldn't know).

    >
    > I made it clear on multiple occasions that the phrases "pointer to" and
    > "points to" can mean different things *if* we are being less formal
    > (i.e. not technically accurate):
    >
    > int* p = new int[42];
    >
    > 1) 'p' is a pointer to an 'int';
    > 2) 'p' is not a pointer to an array of 'int';
    > 3) 'p' points to the first element of an array of 'int'
    > 4) 'p' points to an array of 'int'.
    >
    > (1) and (2) both describe the *type* of 'p' whilst (3) and (4) describe
    > runtime properties (i.e. the *objects* pointed to).
    >
    > If we are being more formal (i.e. technically accurate) then I would
    > consider (4) to be incorrect.


    Enshrined in the coming Holy Standard (unless it's been changed?):

    24.2.1

    5 Just as a regular /pointer to an array/ guarantees that there
    is a pointer value pointing past the last element of the array,
    so for any iterator type there is an iterator value that points
    past the last element of a corresponding sequence.

    27.7.5

    ...

    template <class charT> unspecified get_time(struct tm* tmb, const
    charT* fmt);

    7 Requires: The argument tmb shall be a valid pointer to an
    object of type struct tm, and the argument fmt shall be a valid
    /pointer to an array/ of objects of type charT with
    char_traits<charT>::length(fmt) elements.

    ...

    template <class charT> unspecified put_time(const struct tm* tmb,
    const charT* fmt);

    9 Requires: The argument tmb shall be a valid pointer to an
    object of type struct tm, and the argument fmt shall be a valid
    /pointer to an array/ of objects of type charT with
    char_traits<charT>::length(fmt) elements.

    lolz ... enjoy your flaming future Leigh.

    KHD
    Keith H Duggar, Jun 14, 2011
    #8
  9. Michael Tsang

    Paul Guest

    "Leigh Johnston" <> wrote in message
    news:...
    > On 14/06/2011 22:24, Keith H Duggar wrote:
    >>
    >> On Jun 14, 1:42 pm, Leigh Johnston<> wrote:
    >>> On 14/06/2011 08:19, gwowen wrote:
    >>>
    >>>> On Jun 13, 2:35 pm, "Alf P. Steinbach /Usenet"<alf.p.steinbach
    >>>> > wrote:
    >>>>> To be fair, it just occurred to me, as an example, that we do say
    >>>>> "pointer to
    >>>>> array of pointers" and not "pointer to first element in an array of
    >>>>> pointers".
    >>>
    >>>> I don't know if anyone's ever suggested that's not a useful
    >>>> colloquialism (well, Leigh maybe, but I wouldn't know).
    >>>
    >>> I made it clear on multiple occasions that the phrases "pointer to" and
    >>> "points to" can mean different things *if* we are being less formal
    >>> (i.e. not technically accurate):
    >>>
    >>> int* p = new int[42];
    >>>
    >>> 1) 'p' is a pointer to an 'int';
    >>> 2) 'p' is not a pointer to an array of 'int';
    >>> 3) 'p' points to the first element of an array of 'int'
    >>> 4) 'p' points to an array of 'int'.
    >>>
    >>> (1) and (2) both describe the *type* of 'p' whilst (3) and (4) describe
    >>> runtime properties (i.e. the *objects* pointed to).
    >>>
    >>> If we are being more formal (i.e. technically accurate) then I would
    >>> consider (4) to be incorrect.

    >>
    >> Enshrined in the coming Holy Standard (unless it's been changed?):
    >>
    >> 24.2.1
    >>
    >> 5 Just as a regular /pointer to an array/ guarantees that there
    >> is a pointer value pointing past the last element of the array,
    >> so for any iterator type there is an iterator value that points
    >> past the last element of a corresponding sequence.
    >>
    >> 27.7.5
    >>
    >> ...
    >>
    >> template<class charT> unspecified get_time(struct tm* tmb, const
    >> charT* fmt);
    >>
    >> 7 Requires: The argument tmb shall be a valid pointer to an
    >> object of type struct tm, and the argument fmt shall be a valid
    >> /pointer to an array/ of objects of type charT with
    >> char_traits<charT>::length(fmt) elements.
    >>
    >> ...
    >>
    >> template<class charT> unspecified put_time(const struct tm* tmb,
    >> const charT* fmt);
    >>
    >> 9 Requires: The argument tmb shall be a valid pointer to an
    >> object of type struct tm, and the argument fmt shall be a valid
    >> /pointer to an array/ of objects of type charT with
    >> char_traits<charT>::length(fmt) elements.
    >>
    >> lolz ... enjoy your flaming future Leigh.
    >>
    >> KHD

    >
    > lolz? So you think that both of the following are a "pointer to an
    > array"?
    >
    > int* p1 = 0;
    > int (*p2)[42] = 0;
    >
    > Interesting. I would have said that only p2 is a "pointer to an array".


    There are no arrays. Both are pointers to nothing.

    > I admire your grasp of what is technically accurate and your ability to
    > quote from a draft ISO standard which you are assuming is infallible.
    >

    Their types do not define what they point to, only what they are capable of
    pointing to.
    p1 can point to an int, an array of integers, nothing.
    p2 can point to an array-type object, an array of array-type objects or
    nothing.
    Paul, Jun 14, 2011
    #9
  10. Michael Tsang

    Öö Tiib Guest

    On Jun 15, 1:07 am, Leigh Johnston <> wrote:
    > On 14/06/2011 22:24, Keith H Duggar wrote:
    >
    >
    >
    >
    >
    >
    >
    > > On Jun 14, 1:42 pm, Leigh Johnston<>  wrote:
    > >> On 14/06/2011 08:19, gwowen wrote:

    >
    > >>> On Jun 13, 2:35 pm, "Alf P. Steinbach /Usenet"<alf.p.steinbach
    > >>> >    wrote:
    > >>>> To be fair, it just occurred to me, as an example, that we do say "pointer to
    > >>>> array of pointers" and not "pointer to first element in an array of pointers".

    >
    > >>> I don't know if anyone's ever suggested that's not a useful
    > >>> colloquialism (well, Leigh maybe, but I wouldn't know).

    >
    > >> I made it clear on multiple occasions that the phrases "pointer to" and
    > >> "points to" can mean different things *if* we are being less formal
    > >> (i.e. not technically accurate):

    >
    > >> int* p = new int[42];

    >
    > >> 1) 'p' is a pointer to an 'int';
    > >> 2) 'p' is not a pointer to an array of 'int';
    > >> 3) 'p' points to the first element of an array of 'int'
    > >> 4) 'p' points to an array of 'int'.

    >
    > >> (1) and (2) both describe the *type* of 'p' whilst (3) and (4) describe
    > >> runtime properties (i.e. the *objects* pointed to).

    >
    > >> If we are being more formal (i.e. technically accurate) then I would
    > >> consider (4) to be incorrect.

    >
    > > Enshrined in the coming Holy Standard (unless it's been changed?):

    >
    > > 24.2.1

    >
    > >     5 Just as a regular /pointer to an array/ guarantees that there
    > >     is a pointer value pointing past the last element of the array,
    > >     so for any iterator type there is an iterator value that points
    > >     past the last element of a corresponding sequence.

    >
    > > 27.7.5

    >
    > >     ...

    >
    > >     template<class charT>  unspecified get_time(struct tm* tmb, const
    > > charT* fmt);

    >
    > >     7 Requires: The argument tmb shall be a valid pointer to an
    > >     object of type struct tm, and the argument fmt shall be a valid
    > >     /pointer to an array/ of objects of type charT with
    > >     char_traits<charT>::length(fmt) elements.

    >
    > >     ...

    >
    > >     template<class charT>  unspecified put_time(const struct tm* tmb,
    > > const charT* fmt);

    >
    > >     9 Requires: The argument tmb shall be a valid pointer to an
    > >     object of type struct tm, and the argument fmt shall be a valid
    > >     /pointer to an array/ of objects of type charT with
    > >     char_traits<charT>::length(fmt) elements.

    >
    > > lolz ... enjoy your flaming future Leigh.

    >
    > > KHD

    >
    > lolz?  So you think that both of the following are a "pointer to an array"?
    >
    > int* p1 = 0;
    > int (*p2)[42] = 0;
    >
    > Interesting.  I would have said that only p2 is a "pointer to an array"..
    >   I admire your grasp of what is technically accurate and your ability
    > to quote from a draft ISO standard which you are assuming is infallible.


    That is one point where Paul is right that most of us really call
    "pointer to first element of array" as "pointer to array". We don't
    use constructs like "int (*p2)[42] = 0;" enough to call them with some
    special name. So these are "nothing" ... we simply don't call them ...
    and therefore no conflicts arise.
    Öö Tiib, Jun 14, 2011
    #10
  11. On Jun 14, 6:40 pm, Öö Tiib <> wrote:
    > On Jun 15, 1:07 am, Leigh Johnston <> wrote:
    > > On 14/06/2011 22:24, Keith H Duggar wrote:
    > > > On Jun 14, 1:42 pm, Leigh Johnston<>  wrote:
    > > >> On 14/06/2011 08:19, gwowen wrote:
    > > >>> On Jun 13, 2:35 pm, "Alf P. Steinbach /Usenet"<alf.p.steinbach
    > > >>> >    wrote:
    > > >>>> To be fair, it just occurred to me, as an example, that we do say "pointer to
    > > >>>> array of pointers" and not "pointer to first element in an array of pointers".

    >
    > > >>> I don't know if anyone's ever suggested that's not a useful
    > > >>> colloquialism (well, Leigh maybe, but I wouldn't know).

    >
    > > >> I made it clear on multiple occasions that the phrases "pointer to" and
    > > >> "points to" can mean different things *if* we are being less formal
    > > >> (i.e. not technically accurate):

    >
    > > >> int* p = new int[42];

    >
    > > >> 1) 'p' is a pointer to an 'int';
    > > >> 2) 'p' is not a pointer to an array of 'int';
    > > >> 3) 'p' points to the first element of an array of 'int'
    > > >> 4) 'p' points to an array of 'int'.

    >
    > > >> (1) and (2) both describe the *type* of 'p' whilst (3) and (4) describe
    > > >> runtime properties (i.e. the *objects* pointed to).

    >
    > > >> If we are being more formal (i.e. technically accurate) then I would
    > > >> consider (4) to be incorrect.

    >
    > > > Enshrined in the coming Holy Standard (unless it's been changed?):

    >
    > > > 24.2.1

    >
    > > >     5 Just as a regular /pointer to an array/ guarantees that there
    > > >     is a pointer value pointing past the last element of the array,
    > > >     so for any iterator type there is an iterator value that points
    > > >     past the last element of a corresponding sequence.

    >
    > > > 27.7.5

    >
    > > >     ...

    >
    > > >     template<class charT>  unspecified get_time(struct tm* tmb,const
    > > > charT* fmt);

    >
    > > >     7 Requires: The argument tmb shall be a valid pointer to an
    > > >     object of type struct tm, and the argument fmt shall be a valid
    > > >     /pointer to an array/ of objects of type charT with
    > > >     char_traits<charT>::length(fmt) elements.

    >
    > > >     ...

    >
    > > >     template<class charT>  unspecified put_time(const struct tm* tmb,
    > > > const charT* fmt);

    >
    > > >     9 Requires: The argument tmb shall be a valid pointer to an
    > > >     object of type struct tm, and the argument fmt shall be a valid
    > > >     /pointer to an array/ of objects of type charT with
    > > >     char_traits<charT>::length(fmt) elements.

    >
    > > > lolz ... enjoy your flaming future Leigh.

    >
    > > > KHD

    >
    > > lolz?  So you think that both of the following are a "pointer to an array"?

    >
    > > int* p1 = 0;
    > > int (*p2)[42] = 0;

    >
    > > Interesting.  I would have said that only p2 is a "pointer to an array".
    > >   I admire your grasp of what is technically accurate and your ability
    > > to quote from a draft ISO standard which you are assuming is infallible..

    >
    > That is one point where Paul is right that most of us really call
    > "pointer to first element of array" as "pointer to array". We don't
    > use constructs like "int (*p2)[42] = 0;" enough to call them with some
    > special name. So these are "nothing" ... we simply don't call them ...
    > and therefore no conflicts arise.


    There is a subtlety however. Note that the standard uses both the
    term "pointer to /an/ array" and the term "pointer to array". Note
    the difference of an "an". Furthermore, from some searching of the
    draft it seems to only use the "an" form for the T * type (ie what
    Paul wants to call "pointer to an array") and only uses the sans-
    "an" form for the T (*)[...] type.

    It makes some sense given that "an" connotes a particular /object/
    and so directs one to think about the dynamic value of the pointer
    and the object pointed to rather than the type of the pointer.

    KHD
    Keith H Duggar, Jun 15, 2011
    #11
  12. Michael Tsang

    Paul Guest

    "Leigh Johnston" <> wrote in message
    news:p...
    > On 14/06/2011 22:22, Paul wrote:
    >>
    >> "Leigh Johnston" <> wrote in message
    >> news:p...
    >>> On 14/06/2011 08:19, gwowen wrote:
    >>>> On Jun 13, 2:35 pm, "Alf P. Steinbach /Usenet"<alf.p.steinbach
    >>>> > wrote:
    >>>>> To be fair, it just occurred to me, as an example, that we do say
    >>>>> "pointer to
    >>>>> array of pointers" and not "pointer to first element in an array of
    >>>>> pointers".
    >>>>
    >>>> I don't know if anyone's ever suggested that's not a useful
    >>>> colloquialism (well, Leigh maybe, but I wouldn't know).
    >>>
    >>> I made it clear on multiple occasions that the phrases "pointer to"
    >>> and "points to" can mean different things *if* we are being less
    >>> formal (i.e. not technically accurate):
    >>>

    >> It is perfectly acceptable to say it's a "pointer to.." . and to mean
    >> exactly the same as "it points to", because its very slight difference
    >> is only grammatical.
    >>
    >> If you want to say it's "type is pointer to.." then say that , it's
    >> inaccurate to leave out the 'type' word and assume your definition of
    >> the term "a pointer to" always can mean is "type pointer to" because
    >> your interpretation is a sloppy interpretation and simply a shorthand
    >> version of saying "it's type is pointer to".
    >>
    >>> int* p = new int[42];
    >>>
    >>> 1) 'p' is a pointer to an 'int';
    >>> 2) 'p' is not a pointer to an array of 'int';
    >>> 3) 'p' points to the first element of an array of 'int'
    >>> 4) 'p' points to an array of 'int'.
    >>>
    >>> (1) and (2) both describe the *type* of 'p' whilst (3) and (4)
    >>> describe runtime properties (i.e. the *objects* pointed to).
    >>>
    >>> If we are being more formal (i.e. technically accurate) then I would
    >>> consider (4) to be incorrect.
    >>>

    >>
    >> This is a pointer to the right hand side of the page... ---->
    >> It's "pointer to" the rhs of the page because it "points to" the rhs of
    >> the page.
    >> Both terms mean exactly the same thing but are used in a slightly
    >> different grammatical context.
    >>
    >> You are obviously very confused by the english language. Go away and try
    >> to find some latin quotation so you can come back and disprove me.

    >
    > My understanding of the English language informs me that "pointer" is a
    > noun and "points" is a verb. A noun is not "exactly the same thing" as a
    > verb; it is obvious to me who is having the problem with the English
    > language.
    >

    Congratulations, you understand the difference between a noun and a verb.

    The expression "X is a pointer to Y's" is telling us what X can point to.
    The expression "X points to Y's" is also telling us what X can point to.

    Both terms tell us exactly the same thing, they are only different forms of
    vocabulary
    Paul, Jun 16, 2011
    #12
  13. Michael Tsang

    Paul Guest

    "Leigh Johnston" <> wrote in message
    news:...
    >>>>>>> To be fair, it just occurred to me, as an example, that we do say
    >>>>>>> "pointer to
    >>>>>>> array of pointers" and not "pointer to first element in an array of
    >>>>>>> pointers".
    >>>>>>
    >>>>>> I don't know if anyone's ever suggested that's not a useful
    >>>>>> colloquialism (well, Leigh maybe, but I wouldn't know).
    >>>>>
    >>>>> I made it clear on multiple occasions that the phrases "pointer to"
    >>>>> and "points to" can mean different things *if* we are being less
    >>>>> formal (i.e. not technically accurate):
    >>>>>
    >>>> It is perfectly acceptable to say it's a "pointer to.." . and to mean
    >>>> exactly the same as "it points to", because its very slight difference
    >>>> is only grammatical.
    >>>>
    >>>> If you want to say it's "type is pointer to.." then say that , it's
    >>>> inaccurate to leave out the 'type' word and assume your definition of
    >>>> the term "a pointer to" always can mean is "type pointer to" because
    >>>> your interpretation is a sloppy interpretation and simply a shorthand
    >>>> version of saying "it's type is pointer to".
    >>>>
    >>>>> int* p = new int[42];
    >>>>>
    >>>>> 1) 'p' is a pointer to an 'int';
    >>>>> 2) 'p' is not a pointer to an array of 'int';
    >>>>> 3) 'p' points to the first element of an array of 'int'
    >>>>> 4) 'p' points to an array of 'int'.
    >>>>>
    >>>>> (1) and (2) both describe the *type* of 'p' whilst (3) and (4)
    >>>>> describe runtime properties (i.e. the *objects* pointed to).
    >>>>>
    >>>>> If we are being more formal (i.e. technically accurate) then I would
    >>>>> consider (4) to be incorrect.
    >>>>>
    >>>>
    >>>> This is a pointer to the right hand side of the page... ---->
    >>>> It's "pointer to" the rhs of the page because it "points to" the rhs of
    >>>> the page.
    >>>> Both terms mean exactly the same thing but are used in a slightly
    >>>> different grammatical context.
    >>>>
    >>>> You are obviously very confused by the english language. Go away and
    >>>> try
    >>>> to find some latin quotation so you can come back and disprove me.
    >>>
    >>> My understanding of the English language informs me that "pointer" is
    >>> a noun and "points" is a verb. A noun is not "exactly the same thing"
    >>> as a verb; it is obvious to me who is having the problem with the
    >>> English language.
    >>>

    >> Congratulations, you understand the difference between a noun and a verb.
    >>
    >> The expression "X is a pointer to Y's" is telling us what X can point to.
    >> The expression "X points to Y's" is also telling us what X can point to.
    >>
    >> Both terms tell us exactly the same thing, they are only different forms
    >> of vocabulary

    >
    > In C++ (or even in OO) the term "is a" or "is-a" is generally referring to
    > *types* so when we say "X is a pointer to int" we are describing the type
    > of 'X' not the type of the object 'X' happens to be pointing to (or into)
    > at runtime.
    >


    If you want to refer to the type then say "X is of type, pointer to Y".

    Pointers don't point to types they point to objects, or memory locations
    that contain data. A pointer of type int* can point to integer objects, or
    nothing at all.

    int* p1 = new int;
    int* p2 = new int[22];
    int* p3=0;

    p1 points to a single integer, p2 points to an array of integers and p3
    points to nothing at all.
    Paul, Jun 16, 2011
    #13
  14. Michael Tsang

    Paul Guest

    "Leigh Johnston" <> wrote in message
    news:...
    > On 16/06/2011 20:06, Paul wrote:
    >>
    >> "Leigh Johnston" <> wrote in message
    >> news:...
    >>>>>>>>> To be fair, it just occurred to me, as an example, that we do say
    >>>>>>>>> "pointer to
    >>>>>>>>> array of pointers" and not "pointer to first element in an array
    >>>>>>>>> of
    >>>>>>>>> pointers".
    >>>>>>>>
    >>>>>>>> I don't know if anyone's ever suggested that's not a useful
    >>>>>>>> colloquialism (well, Leigh maybe, but I wouldn't know).
    >>>>>>>
    >>>>>>> I made it clear on multiple occasions that the phrases "pointer to"
    >>>>>>> and "points to" can mean different things *if* we are being less
    >>>>>>> formal (i.e. not technically accurate):
    >>>>>>>
    >>>>>> It is perfectly acceptable to say it's a "pointer to.." . and to mean
    >>>>>> exactly the same as "it points to", because its very slight
    >>>>>> difference
    >>>>>> is only grammatical.
    >>>>>>
    >>>>>> If you want to say it's "type is pointer to.." then say that , it's
    >>>>>> inaccurate to leave out the 'type' word and assume your definition of
    >>>>>> the term "a pointer to" always can mean is "type pointer to" because
    >>>>>> your interpretation is a sloppy interpretation and simply a shorthand
    >>>>>> version of saying "it's type is pointer to".
    >>>>>>
    >>>>>>> int* p = new int[42];
    >>>>>>>
    >>>>>>> 1) 'p' is a pointer to an 'int';
    >>>>>>> 2) 'p' is not a pointer to an array of 'int';
    >>>>>>> 3) 'p' points to the first element of an array of 'int'
    >>>>>>> 4) 'p' points to an array of 'int'.
    >>>>>>>
    >>>>>>> (1) and (2) both describe the *type* of 'p' whilst (3) and (4)
    >>>>>>> describe runtime properties (i.e. the *objects* pointed to).
    >>>>>>>
    >>>>>>> If we are being more formal (i.e. technically accurate) then I would
    >>>>>>> consider (4) to be incorrect.
    >>>>>>>
    >>>>>>
    >>>>>> This is a pointer to the right hand side of the page... ---->
    >>>>>> It's "pointer to" the rhs of the page because it "points to" the
    >>>>>> rhs of
    >>>>>> the page.
    >>>>>> Both terms mean exactly the same thing but are used in a slightly
    >>>>>> different grammatical context.
    >>>>>>
    >>>>>> You are obviously very confused by the english language. Go away
    >>>>>> and try
    >>>>>> to find some latin quotation so you can come back and disprove me.
    >>>>>
    >>>>> My understanding of the English language informs me that "pointer" is
    >>>>> a noun and "points" is a verb. A noun is not "exactly the same thing"
    >>>>> as a verb; it is obvious to me who is having the problem with the
    >>>>> English language.
    >>>>>
    >>>> Congratulations, you understand the difference between a noun and a
    >>>> verb.
    >>>>
    >>>> The expression "X is a pointer to Y's" is telling us what X can point
    >>>> to.
    >>>> The expression "X points to Y's" is also telling us what X can point
    >>>> to.
    >>>>
    >>>> Both terms tell us exactly the same thing, they are only different
    >>>> forms
    >>>> of vocabulary
    >>>
    >>> In C++ (or even in OO) the term "is a" or "is-a" is generally
    >>> referring to *types* so when we say "X is a pointer to int" we are
    >>> describing the type of 'X' not the type of the object 'X' happens to
    >>> be pointing to (or into) at runtime.
    >>>

    >>
    >> If you want to refer to the type then say "X is of type, pointer to Y".
    >>
    >> Pointers don't point to types they point to objects, or memory locations
    >> that contain data. A pointer of type int* can point to integer objects,
    >> or nothing at all.
    >>
    >> int* p1 = new int;
    >> int* p2 = new int[22];
    >> int* p3=0;
    >>
    >> p1 points to a single integer, p2 points to an array of integers and p3
    >> points to nothing at all.

    >
    > p2 points to the first element of an array of integers; crucially what do
    > we say p2 points to if we do:
    >
    > ++p2;
    >
    > Continuing to say that p2 points to an array when it doesn't point to the
    > first element of an array is confusing at best.
    >


    No p2 points to an array of integer objects.

    I've told you before you can point to a banana in a bunch yet you also point
    to the bunch of bananas at the same time.
    Paul, Jun 16, 2011
    #14
  15. Michael Tsang

    Paul Guest

    "io_x" <> wrote in message
    news:4dfb080f$0$40243$...
    >
    > "Paul" <> ha scritto nel messaggio
    > news:kvsKp.6262$2...
    >> If you want to refer to the type then say "X is of type, pointer to Y".
    >>
    >> Pointers don't point to types they point to objects, or memory locations

    >
    > pointers point to memory, in memory can be object or not


    That is more or less what I wrote but having reviewed the holy standard it
    states:
    "A pointer to objects of type T is referred to as a "pointer to T.""

    So I guess a pointer can point to a type in a sense that it can point to an
    object of type X.
    However I don't think this is the generally accepted defintion of what a
    pointer points-to, I stick to my original view that a pointer points to
    memory locations, or objects stored there, which you seem to agree with.

    >
    >> that contain data. A pointer of type int* can point to integer objects,
    >> or
    >> nothing at all.
    >>
    >> int* p1 = new int;
    >> int* p2 = new int[22];
    >> int* p3=0;
    >>
    >> p1 points to a single integer, p2 points to an array of integers and p3
    >> points
    >> to nothing at all.

    >
    > p3 point to address 0 in the memory
    >


    I think this value is used to represent a null pointer because it is not a
    valid addressable address. I agree that in some contexts the pointer can be
    seen to point to the address 0 but remember that a pointers' value is not
    always a real address and it may be added to a base pointer where the result
    would not be address 0 in memory.

    Note: 0 may be a valid address on some system. IDK.
    Paul, Jun 17, 2011
    #15
  16. Michael Tsang

    Paul Guest

    "Leigh Johnston" <> wrote in message
    news:...
    > On 16/06/2011 23:05, Paul wrote:
    >>
    >> "Leigh Johnston" <> wrote in message
    >> news:...
    >>> On 16/06/2011 20:06, Paul wrote:
    >>>>
    >>>> "Leigh Johnston" <> wrote in message
    >>>> news:...
    >>>>>>>>>>> To be fair, it just occurred to me, as an example, that we do
    >>>>>>>>>>> say
    >>>>>>>>>>> "pointer to
    >>>>>>>>>>> array of pointers" and not "pointer to first element in an
    >>>>>>>>>>> array of
    >>>>>>>>>>> pointers".
    >>>>>>>>>>
    >>>>>>>>>> I don't know if anyone's ever suggested that's not a useful
    >>>>>>>>>> colloquialism (well, Leigh maybe, but I wouldn't know).
    >>>>>>>>>
    >>>>>>>>> I made it clear on multiple occasions that the phrases "pointer
    >>>>>>>>> to"
    >>>>>>>>> and "points to" can mean different things *if* we are being less
    >>>>>>>>> formal (i.e. not technically accurate):
    >>>>>>>>>
    >>>>>>>> It is perfectly acceptable to say it's a "pointer to.." . and to
    >>>>>>>> mean
    >>>>>>>> exactly the same as "it points to", because its very slight
    >>>>>>>> difference
    >>>>>>>> is only grammatical.
    >>>>>>>>
    >>>>>>>> If you want to say it's "type is pointer to.." then say that , it's
    >>>>>>>> inaccurate to leave out the 'type' word and assume your
    >>>>>>>> definition of
    >>>>>>>> the term "a pointer to" always can mean is "type pointer to"
    >>>>>>>> because
    >>>>>>>> your interpretation is a sloppy interpretation and simply a
    >>>>>>>> shorthand
    >>>>>>>> version of saying "it's type is pointer to".
    >>>>>>>>
    >>>>>>>>> int* p = new int[42];
    >>>>>>>>>
    >>>>>>>>> 1) 'p' is a pointer to an 'int';
    >>>>>>>>> 2) 'p' is not a pointer to an array of 'int';
    >>>>>>>>> 3) 'p' points to the first element of an array of 'int'
    >>>>>>>>> 4) 'p' points to an array of 'int'.
    >>>>>>>>>
    >>>>>>>>> (1) and (2) both describe the *type* of 'p' whilst (3) and (4)
    >>>>>>>>> describe runtime properties (i.e. the *objects* pointed to).
    >>>>>>>>>
    >>>>>>>>> If we are being more formal (i.e. technically accurate) then I
    >>>>>>>>> would
    >>>>>>>>> consider (4) to be incorrect.
    >>>>>>>>>
    >>>>>>>>
    >>>>>>>> This is a pointer to the right hand side of the page... ---->
    >>>>>>>> It's "pointer to" the rhs of the page because it "points to" the
    >>>>>>>> rhs of
    >>>>>>>> the page.
    >>>>>>>> Both terms mean exactly the same thing but are used in a slightly
    >>>>>>>> different grammatical context.
    >>>>>>>>
    >>>>>>>> You are obviously very confused by the english language. Go away
    >>>>>>>> and try
    >>>>>>>> to find some latin quotation so you can come back and disprove me.
    >>>>>>>
    >>>>>>> My understanding of the English language informs me that "pointer"
    >>>>>>> is
    >>>>>>> a noun and "points" is a verb. A noun is not "exactly the same
    >>>>>>> thing"
    >>>>>>> as a verb; it is obvious to me who is having the problem with the
    >>>>>>> English language.
    >>>>>>>
    >>>>>> Congratulations, you understand the difference between a noun and a
    >>>>>> verb.
    >>>>>>
    >>>>>> The expression "X is a pointer to Y's" is telling us what X can point
    >>>>>> to.
    >>>>>> The expression "X points to Y's" is also telling us what X can
    >>>>>> point to.
    >>>>>>
    >>>>>> Both terms tell us exactly the same thing, they are only different
    >>>>>> forms
    >>>>>> of vocabulary
    >>>>>
    >>>>> In C++ (or even in OO) the term "is a" or "is-a" is generally
    >>>>> referring to *types* so when we say "X is a pointer to int" we are
    >>>>> describing the type of 'X' not the type of the object 'X' happens to
    >>>>> be pointing to (or into) at runtime.
    >>>>>
    >>>>
    >>>> If you want to refer to the type then say "X is of type, pointer to Y".
    >>>>
    >>>> Pointers don't point to types they point to objects, or memory
    >>>> locations
    >>>> that contain data. A pointer of type int* can point to integer objects,
    >>>> or nothing at all.
    >>>>
    >>>> int* p1 = new int;
    >>>> int* p2 = new int[22];
    >>>> int* p3=0;
    >>>>
    >>>> p1 points to a single integer, p2 points to an array of integers and p3
    >>>> points to nothing at all.
    >>>
    >>> p2 points to the first element of an array of integers; crucially what
    >>> do we say p2 points to if we do:
    >>>
    >>> ++p2;
    >>>
    >>> Continuing to say that p2 points to an array when it doesn't point to
    >>> the first element of an array is confusing at best.
    >>>

    >>
    >> No p2 points to an array of integer objects.
    >>
    >> I've told you before you can point to a banana in a bunch yet you also
    >> point to the bunch of bananas at the same time.

    >
    > You have told all of us your crazy analogies before; crazy analogies that
    > remain crazy no matter how many times you repeat them or vary them.
    >
    > Pointing to a banana is not the same as pointing to a bunch of bananas.

    It is if the pointed-to banana is part of a bunch. You cannot point to an
    individual banana in a bunch without also pointing at the bunch of bananas.

    > 'p2' is a pointer to a single 'int' not an array of 'int's.
    >

    The pointer is pointing to 22 objects of type int. Not one single object.
    Paul, Jun 17, 2011
    #16
  17. Michael Tsang

    Paul Guest

    "Leigh Johnston" <> wrote in message
    news:...
    > On 17/06/2011 18:41, Paul wrote:
    >>

    <snip>
    >>>>>>>
    >>>>>>
    >>>>>> If you want to refer to the type then say "X is of type, pointer to
    >>>>>> Y".
    >>>>>>
    >>>>>> Pointers don't point to types they point to objects, or memory
    >>>>>> locations
    >>>>>> that contain data. A pointer of type int* can point to integer
    >>>>>> objects,
    >>>>>> or nothing at all.
    >>>>>>
    >>>>>> int* p1 = new int;
    >>>>>> int* p2 = new int[22];
    >>>>>> int* p3=0;
    >>>>>>
    >>>>>> p1 points to a single integer, p2 points to an array of integers
    >>>>>> and p3
    >>>>>> points to nothing at all.
    >>>>>
    >>>>> p2 points to the first element of an array of integers; crucially what
    >>>>> do we say p2 points to if we do:
    >>>>>
    >>>>> ++p2;
    >>>>>
    >>>>> Continuing to say that p2 points to an array when it doesn't point to
    >>>>> the first element of an array is confusing at best.
    >>>>>
    >>>>
    >>>> No p2 points to an array of integer objects.
    >>>>
    >>>> I've told you before you can point to a banana in a bunch yet you also
    >>>> point to the bunch of bananas at the same time.
    >>>
    >>> You have told all of us your crazy analogies before; crazy analogies
    >>> that remain crazy no matter how many times you repeat them or vary them.
    >>>
    >>> Pointing to a banana is not the same as pointing to a bunch of bananas.

    >> It is if the pointed-to banana is part of a bunch. You cannot point to
    >> an individual banana in a bunch without also pointing at the bunch of
    >> bananas.

    >
    > No; if you are pointing to a bunch of bananas you are not pointing to an
    > individual banana. Your analogies are nonsense and/or pointless.
    >

    Yes you are pointing to the bunch yet ALSO a single banana at the same time

    >>
    >>> 'p2' is a pointer to a single 'int' not an array of 'int's.
    >>>

    >> The pointer is pointing to 22 objects of type int. Not one single object.

    >
    > No it isn't, p2 is pointing to the first element of an array of 22 objects
    > of type 'int'.

    Well it points to 22 int objects then.
    If I do ...
    ++p2 , it still points to 22 int objects but it no longer points to the
    first element.

    >
    > I expect you to repeat yourself yet again by contradicting the facts yet
    > again, *yawn*.
    >

    You are the one who disagrees with the majority of the world about it.
    Paul, Jun 17, 2011
    #17
  18. Michael Tsang

    Paul Guest

    "Leigh Johnston" <> wrote in message
    news:...
    > On 17/06/2011 19:40, Paul wrote:
    >>
    >> "Leigh Johnston" <> wrote in message
    >> news:...
    >>> On 17/06/2011 18:41, Paul wrote:
    >>>>

    >> <snip>
    >>>>>>>>>
    >>>>>>>>
    >>>>>>>> If you want to refer to the type then say "X is of type, pointer to
    >>>>>>>> Y".
    >>>>>>>>
    >>>>>>>> Pointers don't point to types they point to objects, or memory
    >>>>>>>> locations
    >>>>>>>> that contain data. A pointer of type int* can point to integer
    >>>>>>>> objects,
    >>>>>>>> or nothing at all.
    >>>>>>>>
    >>>>>>>> int* p1 = new int;
    >>>>>>>> int* p2 = new int[22];
    >>>>>>>> int* p3=0;
    >>>>>>>>
    >>>>>>>> p1 points to a single integer, p2 points to an array of integers
    >>>>>>>> and p3
    >>>>>>>> points to nothing at all.
    >>>>>>>
    >>>>>>> p2 points to the first element of an array of integers; crucially
    >>>>>>> what
    >>>>>>> do we say p2 points to if we do:
    >>>>>>>
    >>>>>>> ++p2;
    >>>>>>>
    >>>>>>> Continuing to say that p2 points to an array when it doesn't point
    >>>>>>> to
    >>>>>>> the first element of an array is confusing at best.
    >>>>>>>
    >>>>>>
    >>>>>> No p2 points to an array of integer objects.
    >>>>>>
    >>>>>> I've told you before you can point to a banana in a bunch yet you
    >>>>>> also
    >>>>>> point to the bunch of bananas at the same time.
    >>>>>
    >>>>> You have told all of us your crazy analogies before; crazy analogies
    >>>>> that remain crazy no matter how many times you repeat them or vary
    >>>>> them.
    >>>>>
    >>>>> Pointing to a banana is not the same as pointing to a bunch of
    >>>>> bananas.
    >>>> It is if the pointed-to banana is part of a bunch. You cannot point to
    >>>> an individual banana in a bunch without also pointing at the bunch of
    >>>> bananas.
    >>>
    >>> No; if you are pointing to a bunch of bananas you are not pointing to
    >>> an individual banana. Your analogies are nonsense and/or pointless.
    >>>

    >> Yes you are pointing to the bunch yet ALSO a single banana at the same
    >> time

    >
    > No you are not.
    >
    >>
    >>>>
    >>>>> 'p2' is a pointer to a single 'int' not an array of 'int's.
    >>>>>
    >>>> The pointer is pointing to 22 objects of type int. Not one single
    >>>> object.
    >>>
    >>> No it isn't, p2 is pointing to the first element of an array of 22
    >>> objects of type 'int'.

    >> Well it points to 22 int objects then.

    >
    > It does not and can not. The type of an array of 22 objects of type 'int'
    > is unrelated to the type 'int' and related types are important when
    > discussing pointers and what can be assigned to them. The C++ standard
    > informs of what the pointer returned from new[] is:
    >

    An array of 22 int's is not unrelated to the int type.

    > "If it is an array, the new-expression returns a pointer to the initial
    > element of the array."
    >
    > It does not return a pointer to an array.


    Yes it does, the first element of an array is not a single element it is
    ...the first element,.... drumroll.... of an array.

    >
    >> If I do ...
    >> ++p2 , it still points to 22 int objects but it no longer points to the
    >> first element.

    >
    > Gibberish.
    >
    >>
    >>>
    >>> I expect you to repeat yourself yet again by contradicting the facts
    >>> yet again, *yawn*.
    >>>

    >> You are the one who disagrees with the majority of the world about it.

    >
    > Paul's fantasy world I am happy to disagree with.
    >

    Whatever.
    Paul, Jun 17, 2011
    #18
  19. On Jun 17, 12:35 pm, Leigh Johnston <> wrote:
    > On 16/06/2011 23:05, Paul wrote:
    > > "Leigh Johnston" <> wrote in message
    > >> On 16/06/2011 20:06, Paul wrote:
    > >>> int* p1 = new int;
    > >>> int* p2 = new int[22];
    > >>> int* p3=0;

    >
    > >>> p1 points to a single integer, p2 points to an array of integers and p3
    > >>> points to nothing at all.

    >
    > >> p2 points to the first element of an array of integers; crucially what
    > >> do we say p2 points to if we do:

    >
    > >> ++p2;

    >
    > >> Continuing to say that p2 points to an array when it doesn't point to
    > >> the first element of an array is confusing at best.

    >
    > > No p2 points to an array of integer objects.

    >
    > > I've told you before you can point to a banana in a bunch yet you also
    > > point to the bunch of bananas at the same time.

    >
    > You have told all of us your crazy analogies before; crazy analogies
    > that remain crazy no matter how many times you repeat them or vary them.
    >
    > Pointing to a banana is not the same as pointing to a bunch of bananas.
    > 'p2' is a pointer to a single 'int' not an array of 'int's.


    According to the draft standard (and I think it is not likely to
    change) p2 is a "pointer to /an/ array" though not a "pointer to
    array". Likewise, ++p2 is also a "pointer to /an/ array" that so
    happens to also be a sub-array.

    So, unless the standard changes, your opinion directly conflicts
    with it; you are wrong and Paul is consistent with the standard.

    KHD
    Keith H Duggar, Jun 18, 2011
    #19
  20. Michael Tsang

    Paul Guest

    "Leigh Johnston" <> wrote in message
    news:p...
    > On 18/06/2011 14:17, Keith H Duggar wrote:
    >> On Jun 17, 12:35 pm, Leigh Johnston<> wrote:
    >>> On 16/06/2011 23:05, Paul wrote:
    >>>> "Leigh Johnston"<> wrote in message
    >>>>> On 16/06/2011 20:06, Paul wrote:
    >>>>>> int* p1 = new int;
    >>>>>> int* p2 = new int[22];
    >>>>>> int* p3=0;
    >>>
    >>>>>> p1 points to a single integer, p2 points to an array of integers and
    >>>>>> p3
    >>>>>> points to nothing at all.
    >>>
    >>>>> p2 points to the first element of an array of integers; crucially what
    >>>>> do we say p2 points to if we do:
    >>>
    >>>>> ++p2;
    >>>
    >>>>> Continuing to say that p2 points to an array when it doesn't point to
    >>>>> the first element of an array is confusing at best.
    >>>
    >>>> No p2 points to an array of integer objects.
    >>>
    >>>> I've told you before you can point to a banana in a bunch yet you also
    >>>> point to the bunch of bananas at the same time.
    >>>
    >>> You have told all of us your crazy analogies before; crazy analogies
    >>> that remain crazy no matter how many times you repeat them or vary them.
    >>>
    >>> Pointing to a banana is not the same as pointing to a bunch of bananas.
    >>> 'p2' is a pointer to a single 'int' not an array of 'int's.

    >>
    >> According to the draft standard (and I think it is not likely to
    >> change) p2 is a "pointer to /an/ array" though not a "pointer to
    >> array". Likewise, ++p2 is also a "pointer to /an/ array" that so
    >> happens to also be a sub-array.
    >>
    >> So, unless the standard changes, your opinion directly conflicts
    >> with it; you are wrong and Paul is consistent with the standard.

    >
    > And according to the draft C standard the term "pointer to an array" is
    > what the draft C++ standard refers to as a "pointer to array". I am of
    > the opinion that the draft C++ standard is in error changing the meaning
    > of "pointer to an array": try applying some common sense.
    >
    > int *p = 0; // pointer to int, pointer to an int


    No , this pointer points to nothing. It can be said it is of "type pointer
    to int", which is often shortened to "pointer to int".
    The context of this is not the same a what is pointed-to, this context is
    referring to the pointers type, or what the pointer is.


    > int (*pa) = 0; // pointer to array, pointer to an array


    Again this pointer points to nothing.
    You are confusing the term "is a pointer to ..whatever", with the context of
    what is pointed-to and what type the pointer is.


    >
    > As these two standards disagree on terminology I would say that you are
    > being premature saying that we are incorrect and that you two trolls who
    > happen to agree with each other are correct.
    >


    int* p=0;
    This pointer can be said to be "a pointer to int" because that is its type.
    It can also be said that this is "a pointer to nothing" because it points to
    nothing.

    One is neither correct or incorrect, each has a different context.
    You seem to think that because the standard uses a particular context the
    other context will be incorrect, but this is not the case.
    Just as it's not the case that because a pointer points to the first element
    of an array it does not also point to the array.

    Both are correct, they are just used in different contexts. For example if
    you pass an array to a function , you pass a pointer to the array. That
    pointer references the array , as a whole, not just one single element. If
    you dereference the pointer you access only one element.
    Paul, Jun 18, 2011
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Johnny
    Replies:
    91
    Views:
    2,532
    mcg73
    Jul 17, 2013
  2. R Paul Johnson

    R Paul Johnson is out of the office.

    R Paul Johnson, Apr 21, 2006, in forum: Python
    Replies:
    3
    Views:
    257
    Terry Reedy
    Apr 22, 2006
  3. Maciek
    Replies:
    1
    Views:
    430
    Maciek
    Aug 9, 2006
  4. Paul
    Replies:
    63
    Views:
    1,206
Loading...

Share This Page