comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Run-time accessibility checks
Date: Wed, 17 Dec 2008 09:54:19 +0100
Date: 2008-12-17T09:54:19+01:00	[thread overview]
Message-ID: <1nhy4g51rsghh$.5ef0p1t5m5i8.dlg@40tude.net> (raw)
In-Reply-To: gi99lq$moq$1@munin.nbi.dk

On Tue, 16 Dec 2008 16:21:00 -0600, Randy Brukardt wrote:

> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
> news:k2ftogbqmojg.yrjw3ldbi604.dlg@40tude.net...
> ...
>>> Moreover, elements of many forms of
>>> container don't have any order, so you can't do anything useful with the
>>> index by itself -- but operations like iteration are still meaningful.
>>
>> No, if index is unordered and not dense, then iteration is meaningless. It
>> is a broken abstraction then. If you want to iterate a container you have
>> to order its elements. That is equivalent to existence some ordered dense
>> index of.
> 
> Not at all. You are saying that "forall" (that is, do something to all 
> elements of a container) is not a useful iteration if the elements don't 
> have an order. That's pretty hard to believe; indeed, the value of an 
> iterator is is specifically because the order of the elements is not 
> specified; without that, there is no way to get all of the elements via 
> their cursors (or indexes, if you prefer).

Well, that is a philosophic-mathematical issue. I am on a constructivist's
position here. You cannot say "forall," without constructing a set in a way
that effectively enumerates its elements, which in turn is equivalent to a
contract on the set and the corresponding (there can be many) index of.
Clearly any set in a computer has such property, but it breaks abstraction.

>> The index can be of the type System.Address, that is no matter.
>> But to be able to iterate is a contract on the container. It is IMO a very
>> bad idea to assume all containers to fulfill this contract.
> 
> I would never want to say *never* (there is always a counter-example), but 
> surely all of the classic containers (including a "bag") need iteration. 
> It's true that the implementation of a "bag" will necessarily impose an 
> order on the elements, but that order is not interesting and shouldn't be 
> considered part of the abstraction. But the ability to get all elements of a 
> bag for processing is a fundamental operation of the container.

That is not a bag then. Consider an implementation of a bag that uses an
RDB as the store. You cannot iterate rows in an RDB. You can do only ones
of a result set. These are different sets, and the second set has an
extremely heavy penalty to build from the first (potentially
Storage_Error). Not providing iteration would be important for safe use.

But I don't see how this all can be an argument for cursor against index.
If the primary index is unordered that does not mean you cannot have
another one ordered. You can provide as many views of the container you
wished. If you want to iterate container in a loop, provide a view on it as
an array indexed by Positive. As simple as that.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2008-12-17  8:54 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-06 10:15 Run-time accessibility checks (was: Construction initialization problem) Dmitry A. Kazakov
2008-12-06 17:10 ` Ludovic Brenta
2008-12-07  8:44   ` Run-time accessibility checks Dmitry A. Kazakov
2008-12-07 14:56     ` Ludovic Brenta
2008-12-07 19:22       ` Dmitry A. Kazakov
2008-12-11  1:03     ` Randy Brukardt
2008-12-11  9:08       ` Dmitry A. Kazakov
2008-12-11  0:55 ` Run-time accessibility checks (was: Construction initialization problem) Randy Brukardt
2008-12-11  9:48   ` Run-time accessibility checks Dmitry A. Kazakov
2008-12-11 11:21     ` Georg Bauhaus
2008-12-11 11:40       ` Dmitry A. Kazakov
2008-12-11 22:15   ` Run-time accessibility checks (was: Construction initialization problem) Randy Brukardt
2008-12-11 22:31     ` Randy Brukardt
2008-12-13  0:49       ` Randy Brukardt
2008-12-13  9:06         ` Run-time accessibility checks Dmitry A. Kazakov
2008-12-16  1:53           ` Randy Brukardt
2008-12-16  9:28             ` Dmitry A. Kazakov
2008-12-16 22:21               ` Randy Brukardt
2008-12-17  8:54                 ` Dmitry A. Kazakov [this message]
2008-12-12  9:21     ` Dmitry A. Kazakov
replies disabled

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