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!newsgate.cistron.nl!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.arcor.de!news.arcor.de!not-for-mail Date: Wed, 06 Jul 2005 16:53:34 +0200 From: Georg Bauhaus Organization: future apps GmbH User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050513 Debian/1.7.8-1 X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: GCC 4.0 Ada.Containers Cursor danger. References: <1120474891.635131.216700@g44g2000cwa.googlegroups.com> <42C98672.3020705@arcor.de> <42cbb631$0$10808$9b4e6d93@newsread4.arcor-online.net> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <42cbf060$0$22784$9b4e6d93@newsread2.arcor-online.net> NNTP-Posting-Date: 06 Jul 2005 16:53:20 MEST NNTP-Posting-Host: c1d265fe.newsread2.arcor-online.net X-Trace: DXC=^1cIK6g`lm7CDTkn::RD0?Q5U85hF6f;4jW\KbG]kaM8U7^]5?JhlB>]RH[mKYL5E;UUng9_FXZ=3>:=P9Ihe`B8@Z?dZ]MOid5 X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:11898 Date: 2005-07-06T16:53:20+02:00 List-Id: Maxim Reznik wrote: > I look in all my Ada programs. There are a few loops per container, > no more that 2 or 3 at once. Because cursors's main purpose is > iteration over containers I think there will be a few cursors per > container usually. Are these inner loops or outer loops? How often are they run? > For instance, Remove will iterate over all cursors for > the container, check target of cursor and set cursor to > No_Element if target match removed element. > The method I propose costs O(cursors per container) performance > penalty. I think it's acceptable cost for safety. Could you indicate which cost you have in mind, and in which cases it is acceptable? E.g. explaining in T(n) etc terms your Remove analysis above? > In rare cases when user encounter performace limits he > could easy implement his own container, Just repeating the word "easily" doesn't convince me that programming NIH containers is an easy task. I find it puzzling that people keep talking safe, safe, safe, and then roll their own containers, thinking this is easy and safe. OTOH, Matthew demonstrates how you can add checking on top of Ada.Containers when you have reason not to trust your Cursors. > with limited functionality. > And he will know exactly where dangling references cound apear. > > Now cursor is like grenade. You don't know what happens if you > use it. Because you can't check is it valid cursor. We don't know what happens if we blindly use a pointer, too. They could have been deallocated without check, for a reason. Cursors aren't fully checked pointers, true. But there is a reason that Unchecked_Deallocation is in the Ada language. You could ban Unchecked_Deallocation for the same reasons you give for banning Cursors.