Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!rutgers!mcnc!rti!sheol!throopw From: throopw@sheol.UUCP (Wayne Throop) Newsgroups: comp.lang.c Subject: Re: Koenig on pointers and arrays Summary: ANSI C adds one more array operation Message-ID: <0370@sheol.UUCP> Date: 20 Jan 90 18:41:34 GMT References: <2804@bingvaxu.cc.binghamton.edu> <2804@bingvaxu.cc.binghamton.edu> Lines: 29 >> From: cjoslyn@bingvaxu.cc.binghamton.edu (Cliff Joslyn) >> "Only two things can be done to an array: determine its size and obtain >> a pointer to element 0 of the array. [...]" >> is the [.. above sentence ..] literally accurate? > From: ark@europa.att.com (Andrew Koenig) > If I really wanted to split hairs, I could have added that you can > take the address of an array (but only in an ANSI compiler). [...] > I don't think of taking the address of an array as being an > array operation, though. There's nothing special about the fact > that it's an array. But there IS something special about it, and that is the automatic promotion of array names to rvalue addresses essentially everywhere. Address-of is a reasonable exception, but it IS an exception, and thus if "sizeof" is an array operation, so should address-of be. Or maybe it is better to class it the other way around... In C there is only ONE array operation, that of yeilding the address of the first element of the array. The subscript operation, which in other languages is an array operation, is in C a pointer arithmetic operation coupled with indirection. In this view, neither sizeof or address-of is an array operation, but are operations that occur for any objects. -- Wayne Throop !mcnc!rti!sheol!throopw or sheol!throopw@rti.rti.org