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,db88d0444fafe8eb X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Surprise in array concatenation 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: <1125544603.561847.32140@g47g2000cwa.googlegroups.com> <14muavojz308w.1ouv7xin79rqu$.dlg@40tude.net> <4318486f$0$24154$9b4e6d93@newsread4.arcor-online.net> <43187a50$0$24162$9b4e6d93@newsread4.arcor-online.net> <11p5i525v2q5d$.17ayuwvqhazo1.dlg@40tude.net> <431a00cb$0$2113$9b4e6d93@newsread2.arcor-online.net> <9s72daxfzb4f.1k7noh1qr5qpg.dlg@40tude.net> <431c465d$0$24150$9b4e6d93@newsread4.arcor-online.net> Date: Mon, 5 Sep 2005 17:50:17 +0200 Message-ID: <79fcfodixv3k$.1m7d28joczncs$.dlg@40tude.net> NNTP-Posting-Date: 05 Sep 2005 17:50:17 MEST NNTP-Posting-Host: 8f515524.newsread4.arcor-online.net X-Trace: DXC=_nm:_\LARHHJ2=Pn8=T1[J:ejgIfPPldDjW\KbG]kaMHea\9g\;7NmE>1S7gCU5=3E[6LHn;2LCVN7enW;^6ZC`D<=9bOTW=MNN X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:4444 Date: 2005-09-05T17:50:17+02:00 List-Id: 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