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!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!stamper.news.atl.earthlink.net!newsread2.news.atl.earthlink.net.POSTED!14bb18d8!not-for-mail Sender: mheaney@MHEANEYX200 Newsgroups: comp.lang.ada Subject: Re: GCC 4.0 Ada.Containers Cursor danger. References: <1120474891.635131.216700@g44g2000cwa.googlegroups.com> <1121573057.159416.274980@g49g2000cwa.googlegroups.com> <1121622050.676894.246740@g14g2000cwa.googlegroups.com> From: Matthew Heaney Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sun, 17 Jul 2005 18:08:09 GMT NNTP-Posting-Host: 24.149.57.125 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.news.atl.earthlink.net 1121623689 24.149.57.125 (Sun, 17 Jul 2005 11:08:09 PDT) NNTP-Posting-Date: Sun, 17 Jul 2005 11:08:09 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: g2news1.google.com comp.lang.ada:3653 Date: 2005-07-17T18:08:09+00:00 List-Id: "Dmitriy Anisimkov" writes: > I understand that using of cursors allows to reduce the number of > routines in the Ada.Cursors. But i'm sure that using a much more > routines without cursors would reduce a potential errors at design > time. You must adduce evidence for this claim. Otherwise we're just debating religion. > Using the *checking* cursors would move error detection into the run > time. Yes, but in your original example, you were complaining about a run-time error. That error is detectable. > So, I know that i could build whatever i need on top of routines with a > cursors. Yes, but that's the point. A general-purpose library must be flexible enough to meet the needs of disparate applications. If you want the library to be strictly key-based (sans cursors), then it's far less flexible, and no longer a general-purpose library. > But I think that Ada standard should try to move design process into > the way where the errors would be avoided at the design time. You want to legislate behavior for everyone. This is wrong. You should only be concerned with your own behavior. If you want only key-based operations, then you can just write a layered abstraction once, and you can use it everywhere. One way is: generic type Key_Type (<>) is limited private; type Element_Type (<>) is limited private; type Container_Type (<>) is limited private; type Cursor_Type is private; with function First (C : CT) return Cursor_Type is <>; with procedure Next (C : in out Cursor_Type) is <>; ... package Generic_Map_Operations is generic with procedure Process (K : KT; E : ET; Stop : in out Boolean) is <>; procedure Generic_Iteration (Container : Container_Type); ... end Generic_Map_Operations;