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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!news2.google.com!newsfeed.gamma.ru!Gamma.RU!npeer.de.kpn-eurorings.net!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: GCC 4.0 Ada.Containers Cursor danger. Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1120474891.635131.216700@g44g2000cwa.googlegroups.com> <42cd064c$0$10817$9b4e6d93@newsread4.arcor-online.net> <42cda8c4$0$22780$9b4e6d93@newsread2.arcor-online.net> <1u3hh2597i4ne$.1ryetugksbmus.dlg@40tude.net> <1120834341.499757.133770@g43g2000cwa.googlegroups.com> <1121093867.964444.232420@g14g2000cwa.googlegroups.com> <42d2bc2d$0$20148$9b4e6d93@newsread2.arcor-online.net> <1121134291.379399.79460@z14g2000cwz.googlegroups.com> <42d46b51$0$18005$9b4e6d93@newsread4.arcor-online.net> <42d6ef47$0$7644$9b4e6d93@newsread2.arcor-online.net> <1eg30i81gqy2a$.ljhncmxt8d7w.dlg@40tude.net> <42d79276$0$16487$9b4e6d93@newsread4.arcor-online.net> Date: Fri, 15 Jul 2005 16:10:12 +0200 Message-ID: <8k0abqxd1i5c.1h33iury20a80.dlg@40tude.net> NNTP-Posting-Date: 15 Jul 2005 16:10:13 MEST NNTP-Posting-Host: 02e25986.newsread2.arcor-online.net X-Trace: DXC=@[O`8>37>PHVg>C^g8i1FIQ5U85hF6f;DjW\KbG]kaMHXY;eg@jLYeL[V5\?:0WmiH[6LHn;2LCVN7enW;^6ZC`D<=9bOTW=MNN X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:3636 Date: 2005-07-15T16:10:13+02:00 List-Id: On Fri, 15 Jul 2005 12:39:50 +0200, Georg Bauhaus wrote: > Dmitry A. Kazakov wrote: > >>> B := {x: x in A | x >= 0}; >>> >> See the well-ordering theorem and then the axiom of choice. (:-)) > > Yes, therefore Ada.Containers can't be contradicting basic > mathematics that much. :-) Ask Goedel! (:-)) >> Think about differences between: >> >> - An unordered set of unordered elements >> - An unordered set of ordered elements >> - An ordered set of unordered elements >> - An ordered set of ordered elements (and these orders are different) > > Can we resolve the name overloading by using > "as if physically positioned" and > "accessible in sort order", respectively, for the moment? > Then there may or may not be an overlap between the two orders in practice. > An implementation may choose to physically position > the elements in sort order in an internal structure, or not. An implementation may choose anything that does not violate the contract. If the contract tells that it is the same order, then I can use it in my program as follows: if Pos_Of_A < Pos_Of_B then pragma Assert (A < B); This program becomes illegal if orders are different. It is all about safety. >>>For me, First and Last (or whatever you call them) *do* make sense >>>for any reasonable notion of a set in programming, sorted or not, >>>even when used in computer science. >> >> Hmm, what about ring buffers? > > You don't mean the two pointers in a ring buffer cannot > make sense? But pointers are unordered in Ada, for many good reasons, BTW. Note also that the designers of Ada 83 knew the difference. This is why we have: for I in A'Range loop ... because for I in A'First..A'Last loop ... could potentially be meaningless. This potential is not used because Ada's ADT is still underdeveloped, nevertheless. >>>I find Cursors useful when I want to put an index set into operations >>>inside a computer. When I'm can use any container, >>>how could I implement index sets without Cursors? >> >> You are mixing implementation and interface. > > How can I think about "putting into operations" with just interfaces? > (In any practical sense of operation inside a computer.) > So how can I implement index sets without Cursors? Index is not Cursor. If you need an indexed collection then it must be one. Plain sets are not indexed. That is, the contract of a plain set does not provide any way of indexing. You can have an indexed collection a subtype of a plain set, not the opposite. [Though Ada.Containers is a macro library following the bad example of STL, but this is another story.] >>>Find is a membership test, how could it not make sense for >>>a set? >> >> No. Find is more general. > > (It is still also a membership test.) No. Because the result is not Boolean. >> [and again, sets could be searchable and not] > > What do you mean by a set container that is used in a program > and that you cannot search? type Square_Matrix is array (...) of Element; Searching in matrices is quite meaningless. Note that multi-dimensional indexed containers have no order, because their indices are unordered. [countable /= has native order, BTW] Now consider a search, which finds one element in your program and another when you pass the same matrix to a FORTRAN program, just because FORTRAN allocates arrays by columns. This is the essence of the C-style of programming. Have fun! > You can't find members, so how > is a set that you cannot search more useful than one in which > you can actually find an element? It is not *a* set. It is a contract of a class of sets. To make this class wide enough to include all interesting sets, the contract should be as weak as possible. This is the whole idea of generic programming. The algorithms based on least premises are more powerful than less generic ones. The trade-off is genericity vs. efficiency. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de