Re: never heard anything like it in my life?

Discussion in 'C++' started by Jumbo, Jan 21, 2004.

  1. Jumbo

    Jumbo Guest

    Want a laugh check out what this guy Ron Natalie said to me. pmsl:

    "Jumbo @uko2.co.uk>" <pcr1000011<nospam> wrote in message
    news:...
    > Would you like a demonstration of how to assign to an array?
    > int intarr[1];
    > intarr[0] =256;
    >

    intarr[0] is NOT an array. It is an int that happens to be in an array.
    You can't assign arrays. They are the only data type in C++ that
    doesn't have assignment semantics.

    I don't know how to reply to this :p

    AHA.
    :)
    Jumbo, Jan 21, 2004
    #1
    1. Advertising

  2. Jumbo

    David Harmon Guest

    On Wed, 21 Jan 2004 23:50:02 -0000 in comp.lang.c++, "Jumbo"
    <pcr1000011<nospam>@uko2.co.uk> was alleged to have written:
    >I don't know how to reply to this :p


    "Thanks for the correction" would do fine.
    David Harmon, Jan 21, 2004
    #2
    1. Advertising

  3. Jumbo

    Howard Guest

    "Jumbo @uko2.co.uk>" <pcr1000011<nospam> wrote in message
    news:...
    > Want a laugh check out what this guy Ron Natalie said to me. pmsl:
    >
    > "Jumbo @uko2.co.uk>" <pcr1000011<nospam> wrote in message
    > news:...
    > > Would you like a demonstration of how to assign to an array?
    > > int intarr[1];
    > > intarr[0] =256;
    > >

    > intarr[0] is NOT an array. It is an int that happens to be in an array.
    > You can't assign arrays. They are the only data type in C++ that
    > doesn't have assignment semantics.
    >
    > I don't know how to reply to this :p
    >
    > AHA.


    Sounds like just a difference in terminology to me. When Ron (and most
    other progarmmers) talk about assigning "to an array", he means assigning to
    the *entire* array, not to an individual member of an array. You obviously
    talk about assigning to a member of an array using the same terminology.
    It's a matter of semantics, not an argument of facts.

    There is no "assignment semantic" for arrays. In other words, the
    assignment operator is not defined for the array type itself, only for its
    members or for pointers to arrays. You can assign values to the members of
    arrays, or to pointers to array data, but not assign the array *directly*.
    For example, this is illegal:

    int a[3] = {1,2,3};
    int b[3];
    b = a; // not valid!

    But of course, you *can* write

    for (int i = 0; i < 3; ++i)
    b = a;

    However, in the normally accepted terminology for programming, the latter is
    not "assigning to an array", but rather "assigning to the members of an
    array". A subtle diffrence, but it is important to be precise in this
    field.

    You can also write:

    int* a = new int[3]; // initialize pointer with address of first element of
    dynamically-allocated array data
    int* b; // uninitialized pointer
    b = a; // assign a to b (copying the address stored in a, not the data
    pointed to by a)

    But again, that is not assigning to an array, it is assigning to a pointer,
    and it simply makes b and a point to the same memory location, and it is
    that (unnamed) location which holds the array itself.

    Many of us wish that C++ was designed so that you *could* do a direct
    assignment to the entire array, as in my first example. That would have
    made things a lot easier. But it's not how the C++ standard was written, so
    we're stuck with it. And in order to say (in English) that such a thing
    cannot be done, the only way to phrase that fact is to say "you cannot
    assign to an array". (How else would you phrase it, in order to be precise
    and not get your statement confused with assigning to a member of an array
    or a pointer to an array, which *are* legal?)

    So Ron's correct, just more careful (specific?) in his terminology than you
    like to be. Give him a break, huh? He's been a great help to a lot of
    people here, and he knows what he's talking about.

    Regards,
    Howard

    (p.s., what's "pmsl" in your post mean?)
    Howard, Jan 22, 2004
    #3
  4. Jumbo

    Old Wolf Guest

    > > Would you like a demonstration of how to assign to an array?
    > > int intarr[1];
    > > intarr[0] =256;
    > >

    > intarr[0] is NOT an array. It is an int that happens to be in an array.
    > You can't assign arrays. They are the only data type in C++ that
    > doesn't have assignment semantics.


    You wrote the following code in an earlier post:

    > > void foo(const char arr1[]){
    > > arr1="ZZZZ";


    and you claimed that this code was allowed, and it was assigning
    to an array.

    I quote verbatim from your earlier post:

    > > You realize that you just disproved your own point. If arr1 in foo() was
    > > an array, the assignment would have been illegal, requiring a
    > > diagnostic.


    > No I have just proved that arrays can be passed to functions.
    > Why would the assignment have been illegal , what's wrong with assigning a
    > character array to a character array?
    > It seems the only thing needing diagnosed is your condition. :)


    > >
    > > Because arr1 is a pointer, you were able to assign a new value to it.

    > So you can't assign new values to an array?


    Now, would you kindly stop trolling.
    (Let me spell it out in case you missed it: earlier you claimed
    that arrays could be assigned to, and now you claim that they can't)

    Reference:
    http://groups.google.com/groups?q=g...UTF-8&selm=
    Old Wolf, Jan 22, 2004
    #4
  5. Old Wolf wrote:
    >>>Would you like a demonstration of how to assign to an array?
    >>>int intarr[1];
    >>>intarr[0] =256;
    >>>

    >>
    >>intarr[0] is NOT an array. It is an int that happens to be in an array.
    >>You can't assign arrays. They are the only data type in C++ that
    >>doesn't have assignment semantics.


    Note that this quote is not from "Jumbo". It's from Ron Natalie. Jumbo
    is quoting it in an effort to show that Ron is clueless. Of course we
    all know that Jumbo is the clueless one and Ron's quote is perfectly
    accurate.

    >
    >
    > Now, would you kindly stop trolling.
    > (Let me spell it out in case you missed it: earlier you claimed
    > that arrays could be assigned to, and now you claim that they can't)


    No, he hasn't changed his claim. If he had then at least he'd have been
    right once. As it is he's been consistently wrong.

    -Kevin
    --
    My email address is valid, but changes periodically.
    To contact me please use the address from a recent posting.
    Kevin Goodsell, Jan 22, 2004
    #5
  6. Jumbo

    Old Wolf Guest

    > Note that this quote is not from "Jumbo". It's from Ron Natalie. Jumbo
    > is quoting it in an effort to show that Ron is clueless. Of course we
    > all know that Jumbo is the clueless one and Ron's quote is perfectly
    > accurate.


    I must apologise. I can only suggest that we senile wolves are
    easily overcome with ineptitude when confronted by uberlame posters.
    Thanks for pointing out the error
    Old Wolf, Jan 23, 2004
    #6
    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. John B

    Anyone heard of fuhnxrfp.dll ?

    John B, Jun 21, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    486
    Juan T. Llibre
    Jun 21, 2005
  2. Soren Kuula
    Replies:
    1
    Views:
    440
    Henry S. Thompson
    Dec 1, 2005
  3. Kevin
    Replies:
    4
    Views:
    412
    Irrwahn Grausewitz
    Oct 17, 2003
  4. user923005
    Replies:
    4
    Views:
    521
    user923005
    Jun 6, 2007
  5. McKirahan

    Y2K? Never heard of it...

    McKirahan, Dec 27, 2004, in forum: Javascript
    Replies:
    7
    Views:
    101
    Douglas Crockford
    Dec 30, 2004
Loading...

Share This Page