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,1116ece181be1aea X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-08 01:57:57 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.stueberl.de!proxad.net!wanadoo.fr!not-for-mail From: Pascal Obry Newsgroups: comp.lang.ada Subject: Re: Counter-proposal for variable arrays Date: 08 Oct 2003 10:57:52 +0200 Organization: Home - http://perso.wanadoo.fr/pascal.obry Message-ID: References: <3F739C1D.4030907@attbi.com> <3F78E850.8010401@comcast.net> <3F797748.3000203@noplace.com> <834clb.uan1.ln@skymaster> <3F79EF18.7060600@comcast.net> <3F7B1076.8060106@comcast.net> <5mknnv4u96qqudrt4bd8n4t1cljp2fjlp8@4ax.com> <1065215180.95094@master.nyc.kbcfp.com> NNTP-Posting-Host: avelizy-103-1-5-135.w80-13.abo.wanadoo.fr Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news-reader4.wanadoo.fr 1065603476 18822 80.13.115.135 (8 Oct 2003 08:57:56 GMT) X-Complaints-To: abuse@wanadoo.fr NNTP-Posting-Date: 8 Oct 2003 08:57:56 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.95 Xref: archiver1.google.com comp.lang.ada:448 Date: 2003-10-08T08:57:56+00:00 List-Id: Ole-Hjalmar Kristensen writes: > It would be a good idea to check your facts before posting. Arrays are > *constant* pointers, so the assignment above will not compile. Right. Should have been "char *ptr1 = malloc (156);" idem for ptr2. > But I agree that arrays are not first class citizens in C/C++. > The relationship with pointers is obvious if you look at the following > relationship, which always holds: > > x[13] == *(x+13) == *(13+x) == 13[x] !!!! > > PO> void proc (char *ptr); > > PO> And into ptr you can pass objects such as: > > PO> ptr1 > > PO> new char[12] > > Yes, there is no range check, just like Fortran. That's not the point. My point is that you can pass ptr1 or "new char[12]" into a "char*" parameter. Hence the fact that this is pointers not arrays. > PO> "whatever" > > Yes, like Ada, C strings are arrays of characters :-) Again that's not the point. In Ada you can't pass "whatever" into a procedure parameter declared as: procedure Proc (Ptr : access Character); In Ada "whatever" is a String, a string is an array: type String is array (Positive range <>) of Character; and there is no relation between Ada String and pointer of characters. > PO> Call this array if you like. > > I do, As you like! Pascal. -- --|------------------------------------------------------ --| Pascal Obry Team-Ada Member --| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE --|------------------------------------------------------ --| http://perso.wanadoo.fr/pascal.obry --| "The best way to travel is by means of imagination" --| --| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595