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!news1.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!news.germany.com!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> <79fcfodixv3k$.1m7d28joczncs$.dlg@40tude.net> <431c8c35$0$2101$9b4e6d93@newsread2.arcor-online.net> <3ufj318nkubi.a5j4dbvaofhc.dlg@40tude.net> <431d82e3$0$24147$9b4e6d93@newsread4.arcor-online.net> <431dbabc$0$24153$9b4e6d93@newsread4.arcor-online.net> Date: Wed, 7 Sep 2005 11:08:47 +0200 Message-ID: <1b8825x3b8wn3.24qm946raz3d$.dlg@40tude.net> NNTP-Posting-Date: 07 Sep 2005 11:08:47 MEST NNTP-Posting-Host: 5eaf289f.newsread2.arcor-online.net X-Trace: DXC=c_]TCAA\WDlXiD6\]5e5enQ5U85hF6f;djW\KbG]kaMhQ>n?D9BSA]lnL]o^6FWH;fWRXZ37ga[7jn919Q4_`VjiB8=X\UUgbkd X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:4493 Date: 2005-09-07T11:08:47+02:00 List-Id: On Tue, 06 Sep 2005 17:51:11 +0200, Georg Bauhaus wrote: > Dmitry A. Kazakov wrote: >> On Tue, 06 Sep 2005 13:52:53 +0200, Georg Bauhaus wrote: >> >> The violation is in inability to construct empty arrays and ranges for some >> types. > > Many kinds of structured data cannot be constructed > from Ada's types because of Ada's rules. How does this violate Ada's > contracts? If those aren't abstract types, it does. > A contract is not necessarily simple, nor without deliberately > chosen limitations. Arbitrary limitations you mean. If an unbounded array type is not allowed to have empty instances, then I expect to see that explicitly specified in the contract. Soon Ada will have never-null access types. It also could have never-empty arrays, but only this way. >> That becomes funny. What is a "finite" value? Is 1/3 finite? What about >> 0.1? (:-)) > > Earlier I said, forget about real numbers (from mathematics) in real > computers. 1/3 is indeed an example in binary computers: An interval > representing two real numbers close to 1/3 is not 1/3, and you cannot > hope to be computing using real numbers using the facilities of a > real computing machine. That is because almost all reals cannot be > represented in a finite computer. Nope. You confuse sets and elements. Any infinite subset of R (and R itself) cannot be represented by *specifying its members*, because they aren't countable. But any real and any finite real subset can. Further any set can be represented by other means. The domain set of a type need not to be countable. Neither you need to count all values of a type in a given program. Did you ever use all possible values of Integer? Nevertheless, you can do all sorts of quite useful things without that. Now imagine that there are more integers than that. Would it change anything for you? Not in a well designed program! Note an important point of Ada design, as opposed to may other languages. In Ada you specify what kind of values you are going to use. You say: My_Integer is range 0..100; -- I don't care about other integers My_Float is digits 8 range 0.0..100.0; -- I don't care about reals outside and in between This is the right way to handle uncountable things without inventing any new "computer" mathematics, where an element is not element and greater is less. >> LOL! Any program represents anything symbolically. > > No, an executing program has an interpretation. > This makes "representing" have a meaning. And meaning is represented by what? (:-)) >> Do you really believe >> that 1 is *the* 1? Did you see a label "made in Heaven" on it? (:-)) > > Type Positive starts at 1 and ends with Positive'Last. ... and it does this not symbolically, but physically by attaching a tiny rubber thread to the Platonic number 1. Right? (:-)) > The fact that A'First doesn't always refer > to an element is not different from the fact that A'Length / 2 > doesn't always refer to an element, even when the array isn't empty. > Of what use is the test A'Length = 0 in this case? A'Length and A'First have different types. Ada is a typed language! You are trying to formulate some generic algorithm which does not work for all index types. This is why it is so important to have a consistent model of indexing and arrays. For an unordered [index] type X it is wrong to assume that: 1. If L in X and U in X then there is always M in X between L and U 2. That M can be computed as (L+U)/2 Examples: hash map, variable length string map etc. The contracts like 1&2 have be stated, not implied ones, if the application have to rely on them. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de