From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1cf653444208df72 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-21 19:10:32 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!jfk3-feed1.news.digex.net!intermedia!news.stealth.net!204.127.161.2.MISMATCH!wn2feed!worldnet.att.net!135.173.83.71!wnfilter1!worldnet-localpost!bgtnsc06-news.ops.worldnet.att.net.POSTED!not-for-mail From: "David Thompson" Newsgroups: comp.lang.ada References: <9pgr68$7pu1@news.cis.okstate.edu> <3bbd6287.346843109@news.cis.dfn.de> <9pkco7$9qe1@news.cis.okstate.edu> <3bc15a16.1317281@news.cis.dfn.de> <9ps9uu$a2g1@news.cis.okstate.edu> <3BC2FD54.69BA446D@sparc01.ftw.rsc.raytheon.com> <9pv54d$9aa1@news.cis.okstate.edu> <3bc40a3f.4768875@news.cis.dfn.de> <9q1ker$aik1@news.cis.okstate.edu> <9q2ki6$9281@news.cis.okstate.edu> <3BC50B78.DDCB07FF@worldnet.att.net> Subject: Re: ada vs. cpp X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 Message-ID: Date: Mon, 22 Oct 2001 02:10:31 GMT NNTP-Posting-Host: 12.89.145.89 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc06-news.ops.worldnet.att.net 1003716631 12.89.145.89 (Mon, 22 Oct 2001 02:10:31 GMT) NNTP-Posting-Date: Mon, 22 Oct 2001 02:10:31 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:15007 Date: 2001-10-22T02:10:31+00:00 List-Id: James Rogers wrote : ... > C has a similar problem with all arrays. The name of the array is > merely a constant pointer to the first element of the array. No > other information about the array is available, such as the upper > bounds, or the end of useful data in the array. Function parameters > for int arrays are passed as "int *". If you want to return a single > int from an array, through the parameter list, you must pass it as > "int *". > Very close but not quite. In BCPL and B an array name truly was (or more precisely designated) a pointer, which wasn't actually constant although changing it was rare. In C the name does actually designate the array lvalue, which in _almost_ all contexts immediately and silently _converts_ to a pointer to the first element, with the results you describe. This conversion (also for functions) is usually called "decay". The same in C++ for C-style arrays but not for std::vector etc. This was done originally so that arrays would work in structures. See the 2HOPL paper at http://cm.bell-labs.com/cm/cs/who/dmr/ . And most of section 6 of the C (comp.lang.c) FAQ. You're right that an array cannot be passed as such, only as a pointer (or within a struct, or in C++ as a reference), but to further confuse people unfamiliar with this feature you _can_ write the declaration of a function parameter as an array and it is (again silently) "adjusted" to a pointer. And the limitation is really on returning _any type_ from _anywhere_ through a parameter, not just int from array. > C's basic problem is not really strings. Its fundamental problem is > that arrays are not a first class type. > Well, I'd say its fundamental problem is that it was designed as a tolerably good SIL and has been stretched out of shape into a general application and especially GUI language. Different parts of the elephant, maybe. -- - David.Thompson 1 now at worldnet.att.net