comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: GCC 4.0 Ada.Containers Cursor danger.
Date: Fri, 15 Jul 2005 16:10:12 +0200
Date: 2005-07-15T16:10:13+02:00	[thread overview]
Message-ID: <8k0abqxd1i5c.1h33iury20a80.dlg@40tude.net> (raw)
In-Reply-To: 42d79276$0$16487$9b4e6d93@newsread4.arcor-online.net

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



  reply	other threads:[~2005-07-15 14:10 UTC|newest]

Thread overview: 195+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-04 11:01 GCC 4.0 Ada.Containers Cursor danger Dmitriy Anisimkov
2005-07-04 18:56 ` Georg Bauhaus
2005-07-04 19:07   ` Georg Bauhaus
2005-07-05  4:27   ` Dmitriy Anisimkov
2005-07-05 15:01     ` Matthew Heaney
2005-07-06  9:10   ` Maxim Reznik
2005-07-06 10:45     ` Georg Bauhaus
2005-07-06 13:57       ` Maxim Reznik
2005-07-06 14:53         ` Georg Bauhaus
2005-07-06 15:09         ` Matthew Heaney
2005-07-06 16:37           ` Dmitriy Anisimkov
2005-07-06 16:43             ` Matthew Heaney
2005-07-06 22:24         ` Randy Brukardt
2005-07-07 10:23         ` Alex R. Mosteo
2005-07-06 12:41     ` Matthew Heaney
2005-07-06 15:37     ` Matthew Heaney
2005-07-06 21:51   ` Randy Brukardt
2005-07-05 14:51 ` Matthew Heaney
2005-07-05 17:11   ` Dmitriy Anisimkov
2005-07-05 18:02     ` Matthew Heaney
2005-07-05 19:08       ` Dmitriy Anisimkov
2005-07-05 19:26         ` Matthew Heaney
2005-07-05 19:44           ` Dmitriy Anisimkov
2005-07-05 20:06             ` Matthew Heaney
2005-07-06  2:10               ` Dmitriy Anisimkov
2005-07-06 22:44                 ` Randy Brukardt
2005-07-07  3:41                   ` Dmitriy Anisimkov
2005-07-07 19:18                     ` Randy Brukardt
2005-07-08  3:01                       ` Dmitriy Anisimkov
2005-07-09  6:17                         ` Simon Wright
2005-07-11  2:24                           ` Dmitriy Anisimkov
2005-07-11  2:24                           ` Dmitriy Anisimkov
2005-07-06  5:52     ` Martin Dowie
2005-07-06  7:02       ` Dmitriy Anisimkov
2005-07-06  8:02         ` Georg Bauhaus
2005-07-06  8:37           ` Dmitriy Anisimkov
2005-07-06  9:06             ` Pascal Obry
2005-07-06 12:14             ` Georg Bauhaus
2005-07-06  7:53       ` Pascal Obry
2005-07-06  8:44         ` Dmitriy Anisimkov
2005-07-06  9:03           ` Pascal Obry
2005-07-06  9:34             ` Dmitriy Anisimkov
2005-07-06  9:42               ` Pascal Obry
2005-07-06  9:45                 ` Dmitriy Anisimkov
2005-07-06 10:40                   ` Georg Bauhaus
2005-07-06 16:22                     ` Dmitriy Anisimkov
2005-07-06 16:42                       ` Matthew Heaney
2005-07-06 16:59                         ` Dmitriy Anisimkov
2005-07-06 17:12                           ` Matthew Heaney
2005-07-06 18:12                       ` Georg Bauhaus
2005-07-07 12:29                         ` Dmitriy Anisimkov
2005-07-07 12:46                           ` Matthew Heaney
2005-07-07 13:01                             ` Dmitriy Anisimkov
2005-07-07 13:20                               ` Matthew Heaney
2005-07-07 13:54                           ` Georg Bauhaus
2005-07-07 17:56                             ` Dmitriy Anisimkov
2005-07-07 22:12                               ` Georg Bauhaus
2005-07-15 18:03                                 ` Dmitriy Anisimkov
2005-07-16  1:45                                   ` Matthew Heaney
2005-07-17  3:55                                     ` Dmitriy Anisimkov
2005-07-17  4:29                                       ` Matthew Heaney
2005-07-07 19:29                           ` Randy Brukardt
2005-07-08  2:41                             ` Dmitriy Anisimkov
2005-07-06 22:56               ` Randy Brukardt
2005-07-06 22:51         ` Randy Brukardt
2005-07-07  0:24           ` Matthew Heaney
2005-07-07  3:20             ` Randy Brukardt
2005-07-06  7:30     ` Dmitry A. Kazakov
2005-07-06  7:50       ` Georg Bauhaus
2005-07-06  8:11         ` Dmitriy Anisimkov
2005-07-06 11:36         ` Dmitry A. Kazakov
2005-07-06 12:14           ` Georg Bauhaus
2005-07-06 23:07           ` Randy Brukardt
2005-07-07  8:01             ` Dmitry A. Kazakov
2005-07-07 10:38               ` Georg Bauhaus
2005-07-07 13:00                 ` Dmitry A. Kazakov
2005-07-07 13:41                   ` Matthew Heaney
2005-07-07 22:12                   ` Georg Bauhaus
2005-07-08  8:48                     ` Dmitry A. Kazakov
2005-07-08 10:41                       ` Georg Bauhaus
2005-07-08 13:03                         ` Dmitry A. Kazakov
2005-07-08 13:31                           ` Matthew Heaney
2005-07-10  2:12                           ` Randy Brukardt
2005-07-10  8:52                             ` Dmitry A. Kazakov
2005-07-11 10:58                               ` Georg Bauhaus
2005-07-11 12:18                                 ` Dmitry A. Kazakov
2005-07-11 13:50                                   ` Georg Bauhaus
2005-07-11 18:38                               ` Randy Brukardt
2005-07-12  8:44                                 ` Dmitry A. Kazakov
2005-07-12 10:33                                   ` Georg Bauhaus
2005-07-12 20:38                                   ` Randy Brukardt
2005-07-08 13:15                       ` Matthew Heaney
2005-07-08 14:02                         ` Dmitry A. Kazakov
2005-07-08 14:52                           ` Matthew Heaney
2005-07-11 14:57                             ` MMM
2005-07-11 18:36                               ` Georg Bauhaus
2005-07-12  2:11                                 ` MMM
2005-07-12 21:47                                   ` Randy Brukardt
2005-07-13  4:31                                     ` MMM
2005-07-13  1:15                                   ` Georg Bauhaus
2005-07-13  2:46                                     ` Matthew Heaney
2005-07-14  4:11                                     ` Mikhail Terekhov
2005-07-14 12:44                                       ` Matthew Heaney
2005-07-19  1:38                                         ` Mikhail Terekhov
2005-07-19  3:21                                           ` Matthew Heaney
2005-07-14 23:03                                       ` Georg Bauhaus
2005-07-15  8:36                                         ` Dmitry A. Kazakov
2005-07-15 10:39                                           ` Georg Bauhaus
2005-07-15 14:10                                             ` Dmitry A. Kazakov [this message]
2005-07-15 12:10                                           ` Matthew Heaney
2005-07-19  3:51                                             ` Mikhail Terekhov
2005-07-19 11:35                                               ` Matthew Heaney
2005-07-19  3:11                                         ` Mikhail Terekhov
2005-07-19 12:44                                           ` Matthew Heaney
2005-07-20  5:20                                             ` Simon Wright
2005-07-21  2:39                                               ` Matthew Heaney
2005-07-21  3:23                                               ` Randy Brukardt
2005-07-19 23:51                                           ` Randy Brukardt
2005-07-20 15:33                                             ` Robert A Duff
2005-07-11 14:56                         ` MMM
2005-07-11 23:24                           ` Matthew Heaney
2005-07-12  3:05                             ` MMM
2005-07-12  5:32                               ` Simon Wright
2005-07-13  2:41                                 ` MMM
2005-07-12 11:16                               ` Georg Bauhaus
2005-07-16 22:28                                 ` Robert A Duff
2005-07-12 13:32                               ` Marc A. Criley
2005-07-12 14:51                                 ` MMM
2005-07-12 15:35                                   ` Matthew Heaney
2005-07-12 18:40                                     ` MMM
2005-07-12 19:12                                       ` Matthew Heaney
2005-07-12 19:42                                         ` MMM
2005-07-12 20:02                                           ` Georg Bauhaus
2005-07-13  3:52                                             ` MMM
2005-07-12 20:13                                           ` Matthew Heaney
2005-07-12 21:38                                     ` Simon Wright
2005-07-12 17:44                                   ` Marc A. Criley
2005-07-12 18:51                                     ` MMM
2005-07-12 19:15                                       ` Matthew Heaney
2005-07-12 19:47                                         ` Georg Bauhaus
2005-07-13  2:20                                           ` Matthew Heaney
2005-07-12 20:00                                         ` MMM
2005-07-12 20:09                                           ` Georg Bauhaus
2005-07-12 20:15                                           ` Matthew Heaney
2005-07-12 21:01                                           ` Randy Brukardt
2005-07-13  4:16                                             ` MMM
2005-07-19 23:58                                               ` Randy Brukardt
2005-07-12 21:59                                         ` Simon Wright
2005-07-12 20:56                                       ` Randy Brukardt
2005-07-14  5:01                                         ` Mikhail Terekhov
2005-07-20  0:10                                           ` Randy Brukardt
2005-07-07 12:36               ` Matthew Heaney
2005-07-07 12:52             ` Dmitriy Anisimkov
2005-07-07 13:52               ` Georg Bauhaus
2005-07-07 17:49               ` Dmitriy Anisimkov
2005-07-07 18:35                 ` Matthew Heaney
2005-07-08 17:52                   ` Craig Carey
2005-07-07 17:50               ` Dmitriy Anisimkov
2005-07-07 19:47               ` Randy Brukardt
2005-07-08  2:28                 ` Dmitriy Anisimkov
2005-07-09 14:20                   ` Matthew Heaney
2005-07-10  1:51                   ` Randy Brukardt
2005-07-10  5:46                     ` Craig Carey
2005-07-10  6:13                       ` Craig Carey
2005-07-11 17:33                       ` OT: Greg and Colin? (was Re: GCC 4.0 Ada.Containers Cursor danger.) Marc A. Criley
2005-07-06 22:34     ` GCC 4.0 Ada.Containers Cursor danger Randy Brukardt
2005-07-07  0:22       ` Matthew Heaney
2005-07-07  3:17         ` Randy Brukardt
2005-07-08  5:34           ` Jeffrey Carter
2005-07-10  1:53             ` Randy Brukardt
2005-07-10 19:32               ` Jeffrey Carter
2005-07-07  3:24         ` Randy Brukardt
2005-07-16 23:24 ` Matthew Heaney
2005-07-17  4:04   ` Dmitriy Anisimkov
2005-07-17  5:01     ` Matthew Heaney
2005-07-17 17:13       ` Dmitriy Anisimkov
2005-07-17 17:36         ` Matthew Heaney
2005-07-17 17:49           ` Dmitriy Anisimkov
2005-07-17 18:12             ` Matthew Heaney
2005-07-17 17:40       ` Dmitriy Anisimkov
2005-07-17 17:50         ` Dmitriy Anisimkov
2005-07-17 18:08         ` Matthew Heaney
2005-07-19  4:36           ` Mikhail Terekhov
2005-07-20  1:59             ` Matthew Heaney
2005-07-20 14:00               ` Pascal Obry
2005-07-20 14:34                 ` Matthew Heaney
2005-07-20 16:51                   ` Pascal Obry
2005-07-20 16:53                   ` Pascal Obry
2005-07-21  3:18                   ` Randy Brukardt
2005-07-20  2:37             ` Robert I. Eachus
2005-08-02 16:59               ` Craig Carey
2005-08-02 20:55                 ` Simon Wright
2005-07-20  7:20             ` Georg Bauhaus
2005-07-17  9:28     ` Georg Bauhaus
2005-07-17 14:26       ` Matthew Heaney
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox