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-Thread: 103376,703c4f68db81387d X-Google-Thread: 109fba,703c4f68db81387d X-Google-Thread: 115aec,703c4f68db81387d X-Google-Thread: f43e6,703c4f68db81387d X-Google-Attributes: gid103376,gid109fba,gid115aec,gidf43e6,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!newsfeed.stanford.edu!sn-xit-02!sn-xit-01!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: CTips Newsgroups: comp.lang.ada,comp.lang.c++,comp.realtime,comp.software-eng Subject: Re: Teaching new tricks to an old dog (C++ -->Ada) Date: Tue, 08 Mar 2005 15:10:34 -0500 Organization: Posted via Supernews, http://www.supernews.com Message-ID: <112s1lr9j9or133@corp.supernews.com> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.3) Gecko/20040910 X-Accept-Language: en-us, en MIME-Version: 1.0 References: <4229bad9$0$1019$afc38c87@news.optusnet.com.au> <1110032222.447846.167060@g14g2000cwa.googlegroups.com> <871xau9nlh.fsf@insalien.org> <3SjWd.103128$Vf.3969241@news000.worldonline.dk> <87r7iu85lf.fsf@insalien.org> <1110052142.832650@athnrd02> <1110284070.410136.205090@o13g2000cwo.googlegroups.com> <395uqaF5rhu2mU1@individual.net> <112rs0bdr2aftdf@corp.supernews.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@supernews.com Xref: g2news1.google.com comp.lang.ada:8879 comp.lang.c++:44650 comp.realtime:1078 comp.software-eng:4633 Date: 2005-03-08T15:10:34-05:00 List-Id: Pascal Obry wrote: > CTips writes: > > >>Free? Well, lets look at one particular issue: pointers to arbitrary >>locations. In C, its a common idiom to do the following: >> foo(int * p) >> { >> int * z; >> for( i ... ) { >> ... p[i]...; >> } >> z = p; >> } >> >> ... >> foo( &x[lo] ); >> ... >> >>Now, how can *any* language check to see that p[i] is within bounds? > > > Good you asked! Let's code this example in Ada (using Ada and > not C/C++ style, in Ada for the above example we do not need a pointer): > > type T is array (Positive range <>) of Integer; > > procedure Foo (P : in out T) is > Z : Positive; > begin > for I in P'Range loop > ... P(i)...; > -- Here P(i) is always within the bounds, no check needed. > end loop; > Z := P'First; Nope, not z = p[0], z = p; Z is a _pointer_ to int, not an int. > end Foo; > > ... > > Foo (X (Lo .. X'Last)); > > >>Bullsh*t. In several ways, of which two are: > > > Given your assumption about maybe you just don't know Ada. Try again. Show me how sizeof(z) != 8 in Ada. > > Pascal. >