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,f2690a5e963b61b6 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.megapath.net!news.megapath.net.POSTED!not-for-mail NNTP-Posting-Date: Wed, 06 Jul 2005 16:48:26 -0500 From: "Randy Brukardt" Newsgroups: comp.lang.ada References: <1120474891.635131.216700@g44g2000cwa.googlegroups.com> <42C98672.3020705@arcor.de> Subject: Re: GCC 4.0 Ada.Containers Cursor danger. Date: Wed, 6 Jul 2005 16:51:35 -0500 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4952.2800 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4952.2800 Message-ID: NNTP-Posting-Host: 64.32.209.38 X-Trace: sv3-CKnqRF3NYxGRFxeCicXfjj+QZ/CQNoYmhm48eohUPVye6yUvwB4RuFkl33axy2TJ9jbEmKpaQOkuecv!G9YtNEOvYZmzLtVAjMC69BSDrJHrz0GgnMtRhrGO4zvSZ9fiYoy1gk8VnovlzaMHAqtyVL4OXMck X-Complaints-To: abuse@megapath.net X-DMCA-Complaints-To: abuse@megapath.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.31 Xref: g2news1.google.com comp.lang.ada:11908 Date: 2005-07-06T16:51:35-05:00 List-Id: "Georg Bauhaus" wrote in message news:42C98672.3020705@arcor.de... > Dmitriy Anisimkov wrote: > > IMHO the cursors in the Ada.Containers implemented in GCC 4.0 > > dangerouse like pointers in C/C++. > > I think saying that Cursors are as dangerous as Ada pointers > is more to the point. IIRC there are significant > differences between Ada.Containers and STL, more checks i.e. > > Not sure though why Replace_Element doesn't raise an exception, > possibly because messing around with two pointers to the same object > and then deleting the object can lead to erroneous execution: Yes. It's very expensive to make such checks that would be bulletproof (a cursor would need to be a controlled type with an indirect reference to the container, and the container would need to maintain a list of all existence cursors). Thus the checks aren't mandated. However, these checks are relatively easy to make in cases like the one given. And nothing in the standard prevents an implementation from making a check in this case. I believe that Ada implementations ought to make such checks in the easy cases (certainly the Janus/Ada implementation will). One of the real advantages to cursors in this case is that checks *can* be made; if we had used access types directly, no such checks would be possible. One can imagine a debugging version of the containers that made all possible checks, no matter what the cost. (I think my design is good enough for general use, because we can check almost all errors for a small additional cost in the size of cursors.) Randy Brukardt Randy Brukardt