comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Surprise in array concatenation
Date: Mon, 5 Sep 2005 17:50:17 +0200
Date: 2005-09-05T17:50:17+02:00	[thread overview]
Message-ID: <79fcfodixv3k$.1m7d28joczncs$.dlg@40tude.net> (raw)
In-Reply-To: 431c465d$0$24150$9b4e6d93@newsread4.arcor-online.net

On Mon, 05 Sep 2005 15:22:18 +0200, Georg Bauhaus wrote:

> Dmitry A. Kazakov wrote:
> 
> I think I can abbreviate, by answering this one:
> 
>> Huh, who can solve Maxwell's equations for a TV set? Does it mean that you
>> can create one ignoring laws of physics?
> 
> You *are* ignoring the laws of physing in building a TV set
> because no one *knows* whether Maxwell's equations describe
> any particular TV set, and no one *can* perform a complete *test*.

That's a different thing. If you discovered that according to your design
the TV set would violate Ohm's law. What would you check first? The design
or the theory?

> Likewise, a computer might surprise us in suggesting that our
> fine mathematically thought-out program doesn't quite behave exactly
> as we thought, because of the naughty computer thingy and its
> quirks.

You are mixing inadequate and inconsistent models.

>> Re-read what you wrote: an off-bound [array] index is an array bound! Is it
>> "off" or not? (:-))
> 
> We have
>  lo, hi: arrays -> I,
>  item: arrays x I -> values
> 
> If hi is onto [1, 2, ... 5], then item(hi(Some_Array, X)) lies in values,
> provided hi(Some_Array, X) is defined.
> 
> For example, hi(Some_Array, 17) is undefined, generating an exception in
> Ada terms.
> 
> If Some_Array'first = 42, hi(some_array, Some_Array'First) is undefined.
> Exception. Enough consistency here, for my taste.

What about hi >= lo? What about handling Some_Array (Some_Array'First)
failure? Note that it fails not because there is no A'First, but because
the index is wrong? How so? It exists, but wrong! Then what would you do
with modular and enumeration types?

>> Better ADT is what Ada needs.
> 
> Is Ada a Must for you?

Sure. C++ shortens my life!

> These things are built into other programming
> languages.

Like C++? (:-))

>> 1. The cursor have to have "off" values. Consider the type Character,
>> you'll need to extend it with two values, left and right. Presently Ada
>> does not support this.
> 
> Do you insist that every subtype must be associated with an index subtype,
> such that every index value can be used to denote a value from the array?

   subtype I is Index range A'Range; -- This is legal Ada

What I want is freedom. I don't want the compiler to decide for me whether
there must be "off" values or not. The concept of array must be consistent
with index types having no "off" values, like ring buffers. It also should
consistently support arrays over empty index types.

>> 2. There should be a way to construct off-values. That might be very
>> non-trivial. Example: pointers. Try to find a pointer that does not point
>> to some object.
> 
> The Eiffel solution is to (implicitly) have class NONE be an heir
> of every class in the system. So NONE conforms to every type, or every
> type is among the progenitors of NONE.
> There is a single instance of NONE, called Void. A reference that isn't
> attached to some object refers to Void.

This is incompatible with modular and enumeration types. It also has a
distributed overhead. You either will have no by-copy types or will need to
store NONE where one bit would otherwise be enough. Then making a hash
function you'll need to explicitly test for NONE etc.
 
>>>Something that I think is frequently found in math literature ;-)
>> 
>> I'm not a mathematician, so I cannot tell. But I think that the set theory
>> explicitly forbids unbound quantifiers, which would otherwise refer to the
>> set of "all things" (an equivalent of "off-set" thing.) It is no-no.
> 
> You mean that the set to be enumerated is given?

Sure. And in mathematics there is no problem to write:

   forall x in X

The concept:

   for I in A'First..A'Last loop

is more specialized than

   for I in A'Range loop

and even more than

   for X in A loop -- Not Ada!

I in A'First..A'Last that A'Range is 1) ordered, 2) has the lower and upper
bounds, 3) these bounds belong to the array. These assumptions are not
always required. Moreover, for some arrays they are wrong. Consider making
a loop over a ring buffer starting in somewhere the middle. [We have
already debated unordered index types some time ago.] A very practical
principle is to design software with minimal assumptions.

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



  reply	other threads:[~2005-09-05 15:50 UTC|newest]

Thread overview: 108+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-01  3:16 Surprise in array concatenation Gene
2005-09-01  7:55 ` Dmitry A. Kazakov
2005-09-01  8:02   ` Florian Weimer
2005-09-01 11:48     ` Georg Bauhaus
2005-09-01 12:02       ` Lutz Donnerhacke
2005-09-01 13:01         ` Georg Bauhaus
2005-09-01 15:54       ` Florian Weimer
2005-09-01 16:09     ` Robert A Duff
2005-09-05  8:38       ` Jean-Pierre Rosen
2005-09-05 23:52         ` Robert A Duff
2005-09-06  9:03           ` Jean-Pierre Rosen
2005-09-07 17:57         ` adaworks
2005-09-07 20:01           ` Robert A Duff
2005-09-08  8:08             ` Jacob Sparre Andersen
2005-09-07 22:46           ` Jeffrey Carter
2005-09-08  4:43             ` Simon Wright
2005-09-08 10:36               ` Georg Bauhaus
2005-09-08 13:47                 ` Ed Falis
2005-09-08 17:03                   ` Pascal Obry
2005-09-08 16:45               ` Jeffrey Carter
2005-09-08 19:37                 ` Simon Wright
2005-09-08  6:32             ` adaworks
2005-09-08  9:09               ` Jean-Pierre Rosen
2005-09-08 16:56               ` Jeffrey Carter
2005-09-09 14:04                 ` Bob Spooner
2005-09-09 16:17                 ` adaworks
2005-09-23 23:04               ` Randy Brukardt
2005-09-14  8:57           ` Ole-Hjalmar Kristensen
2005-09-23 23:09           ` Randy Brukardt
2005-09-24 10:49             ` Larry Kilgallen
2005-09-24 20:27             ` Lurker
2005-09-25  0:20             ` Robert A Duff
2005-09-25 17:05             ` adaworks
2005-09-01 11:42   ` Georg Bauhaus
2005-09-01 13:59     ` Dmitry A. Kazakov
2005-09-01 15:36       ` Georg Bauhaus
2005-09-01 18:34         ` Dmitry A. Kazakov
2005-09-02 10:43           ` Georg Bauhaus
2005-09-02 13:11             ` Dmitry A. Kazakov
2005-09-02 14:23               ` Georg Bauhaus
2005-09-02 19:48                 ` Dmitry A. Kazakov
2005-09-02 17:21           ` Björn Persson
2005-09-01 16:04   ` Robert A Duff
2005-09-01 18:06     ` Dmitry A. Kazakov
2005-09-02 10:42       ` Georg Bauhaus
2005-09-02 13:20         ` Dmitry A. Kazakov
2005-09-02 14:14           ` Georg Bauhaus
2005-09-02 19:48             ` Dmitry A. Kazakov
2005-09-03 20:01               ` Georg Bauhaus
2005-09-04 10:13                 ` Dmitry A. Kazakov
2005-09-05 13:22                   ` Georg Bauhaus
2005-09-05 15:50                     ` Dmitry A. Kazakov [this message]
2005-09-05 18:20                       ` Georg Bauhaus
2005-09-05 18:31                         ` Georg Bauhaus
2005-09-06  8:20                         ` Dmitry A. Kazakov
2005-09-06 11:52                           ` Georg Bauhaus
2005-09-06 13:46                             ` Dmitry A. Kazakov
2005-09-06 15:51                               ` Georg Bauhaus
2005-09-06 21:32                                 ` Robert A Duff
2005-09-07  9:08                                 ` Dmitry A. Kazakov
2005-09-07 18:20                                   ` Georg Bauhaus
2005-09-07 19:07                                     ` Georg Bauhaus
2005-09-07 21:23                                     ` Dmitry A. Kazakov
2005-09-08 10:27                                       ` Georg Bauhaus
2005-09-08 11:39                                         ` Georg Bauhaus
2005-09-08 13:44                                         ` Dmitry A. Kazakov
2005-09-08 18:18                                           ` Georg Bauhaus
2005-09-09 10:06                                             ` Dmitry A. Kazakov
2005-09-09 12:26                                               ` Georg Bauhaus
2005-09-09 12:29                                               ` Georg Bauhaus
2005-09-01  8:48 ` Jean-Pierre Rosen
2005-09-01 15:57 ` Robert A Duff
2005-09-01 21:42   ` Gene
2005-09-01 22:56     ` tmoran
2005-09-05 15:53       ` Gene
2005-09-05 17:47         ` jimmaureenrogers
2005-09-05 22:13           ` Robert A Duff
2005-09-06  8:24             ` Dmitry A. Kazakov
2005-09-05 19:22         ` Jeffrey R. Carter
2005-09-05 21:54           ` Robert A Duff
2005-09-05 22:50             ` Larry Kilgallen
2005-09-05 23:46               ` Robert A Duff
2005-09-12  3:59                 ` Dave Thompson
2005-09-06 16:02             ` Jeffrey Carter
2005-09-06 21:00               ` Robert A Duff
2005-09-06  5:38         ` Pascal Obry
2005-09-05 21:48       ` Robert A Duff
2005-09-06  5:25         ` tmoran
2005-09-06 14:58           ` Robert A Duff
2005-09-06  9:26         ` Georg Bauhaus
2005-09-06 15:00           ` Robert A Duff
2005-09-07 11:02             ` Thierry Pirot
2005-09-07 20:09               ` Robert A Duff
2005-09-06 13:22         ` Bob Spooner
2005-09-06 15:30           ` Robert A Duff
2005-09-06 16:12             ` Jeffrey Carter
2005-09-06 21:21               ` Robert A Duff
2005-09-02 20:19     ` Jeffrey R. Carter
2005-09-03 12:51     ` Dr. Adrian Wrigley
2005-09-03 14:08       ` Jacob Sparre Andersen
2005-09-05  8:34         ` Jean-Pierre Rosen
2005-09-05  9:32           ` Arrays indexed by fixed point types (Was: Surprise in array concatenation) Jacob Sparre Andersen
2005-09-05 11:07             ` Jean-Pierre Rosen
2005-09-05 15:12               ` Dr. Adrian Wrigley
2005-09-05 12:14             ` Dmitry A. Kazakov
2005-09-05 13:07               ` Jacob Sparre Andersen
2005-09-05 15:10                 ` Dmitry A. Kazakov
2005-09-05 11:29           ` Surprise in array concatenation Dr. Adrian Wrigley
replies disabled

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