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,a3736685ef876ab2 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Wed, 21 Nov 2007 10:18:53 +0100 From: Georg Bauhaus User-Agent: Thunderbird 2.0.0.6 (X11/20071022) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: OO Style with Ada Containers References: <1195082906.420079.195000@d55g2000hsg.googlegroups.com> <1s27rv0gt4ujj$.3e2k326rp54d.dlg@40tude.net> <60e46dc9-d8ca-4f47-9e8a-f90a7d45e752@w28g2000hsf.googlegroups.com> <0319d921-4457-4b47-87f2-3f310aaa3d93@o6g2000hsd.googlegroups.com> <5076f153-d879-43dd-b2c8-ad61eeea241d@d61g2000hsa.googlegroups.com> <4182086a-2968-4c42-b08a-1a30b05fcf63@c29g2000hsa.googlegroups.com> <400347d7-aa93-4175-a3dc-e415ad0d9ca3@i29g2000prf.googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <4743f801$0$16661$9b4e6d93@newsspool3.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 21 Nov 2007 10:18:57 CET NNTP-Posting-Host: a1784220.newsspool3.arcor-online.net X-Trace: DXC=813?b=Z5;fIlU`@c^jLCbJMcF=Q^Z^V3H4Fo<]lROoRA4nDHegD_]REgjFj838gMaJA:ho7QcPOVC Matthew Heaney wrote: > Maciej Sobczak writes: > >> You cannot do arithmetics with cursors. They don't have appropriate >> operators and the examples you shown work with indices, not with >> cursors. Cursors themselves can be only incremented and decremented. > > Actually, I thought about this more and concluded it doesn't matter that much. > C++ requires a uniform interface to allow the instantiation to happen, because > of the way it binds operations (by name). But in Ada you can build a type > adapter on-the-fly (that's the locally declared subprogram stuff, which you > must often do anyway), and furthermore the actual name can differ from the > formal. So not having cursor-based arithmetic isn't such a great loss, since > you can always instantiate the algorithm using the index subtype instead of > using the cursor (as I showed earlier, to pass an array to a generic > algorithm). At the other end of the argument is a hint from Code Complete (McConnell 1993), adding heresy++ 'Think of arrays as sequential structures. Some of the brightest people in computer science have suggested that arrays never be accessed randomly, but only sequentially (Mills and Linger 1986). Their argument is that random accesses in arrays are similar to random "gotos" in a program.' (p251) Since Vectors "is specifically optimized for insertion and deletion at the high end (the end with the higher index) of the container" (A.18.2) following this advice will defeat the purpose of Vectors only partially. ;) At least when used by average programmers (like me) who rarely invent quicksort for slices and such.