Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Re: never heard anything like it in my life? (http://www.velocityreviews.com/forums/t280818-re-never-heard-anything-like-it-in-my-life.html)

Jumbo 01-21-2004 11:50 PM

Re: never heard anything like it in my life?
 
Want a laugh check out what this guy Ron Natalie said to me. pmsl:

"Jumbo @uko2.co.uk>" <pcr1000011<nospam> wrote in message
news:1074695100.709794@news.minx.net.uk...
> 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.
:-)



David Harmon 01-21-2004 11:56 PM

Re: never heard anything like it in my life?
 
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.


Howard 01-22-2004 07:37 PM

Re: never heard anything like it in my life?
 

"Jumbo @uko2.co.uk>" <pcr1000011<nospam> wrote in message
news:1074729603.279695@news.minx.net.uk...
> Want a laugh check out what this guy Ron Natalie said to me. pmsl:
>
> "Jumbo @uko2.co.uk>" <pcr1000011<nospam> wrote in message
> news:1074695100.709794@news.minx.net.uk...
> > 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[i] = a[i];

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?)






Old Wolf 01-22-2004 07:54 PM

Re: never heard anything like it in my life?
 
> > 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:...ws.minx.net.uk

Kevin Goodsell 01-22-2004 08:27 PM

Re: never heard anything like it in my life?
 
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.

Old Wolf 01-23-2004 03:18 AM

Re: never heard anything like it in my life?
 
> 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


All times are GMT. The time now is 05:54 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.