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> Date: Fri, 2 Sep 2005 15:20:13 +0200 Message-ID: NNTP-Posting-Date: 02 Sep 2005 15:20:13 MEST NNTP-Posting-Host: c1ab20b7.newsread2.arcor-online.net X-Trace: DXC=i1>Ao5ZYDELVg>C^g8i1FIQ5U85hF6f;DjW\KbG]kaMHQ>n?D9BSA]LUU`JMhHn\KGWRXZ37ga[7Jn919Q4_`VjIB8=X\UUgbkD X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:4395 Date: 2005-09-02T15:20:13+02:00 List-Id: On Fri, 02 Sep 2005 12:42:06 +0200, Georg Bauhaus wrote: > Dmitry A. Kazakov wrote: >> On 01 Sep 2005 12:04:17 -0400, Robert A Duff wrote: > >>>Heh? You want this: >>> >>> procedure Put(S: String) is >>> begin >>> for I in S'First..S'Last loop -- equivalent to S'Range >>> Put_Char(S(I)); >>> >>>to crash when S = ""? >> >> Yes. > > What is your approach to subranges then? > > function h(s: String) return Unsigned_32 is > prefix: String renames > s(s'first .. s'first + Integer'min(3, s'length - 1)); > result: Unsigned_32 := 0; > begin > for k in prefix'range loop > result := result or Shift_Left(Character'pos(prefix(k)), > (k - prefix'first) * 8); > end loop; > return result; > end h; > > (If you could assume for the moment that there is no > Unchecked_Conversion and not a different/better algorithm etc.) I don't see any problem, so far. Subrange of an empty range is empty. As for the checksum of an empty string it is to be extra defined. You cannot in general case reverse any possible sequence S1, S2, S3, ... to deduce S0. IF the sequence is a series bound by some operation *: SN = x1 * x2 * ...* xN AND * is a group operation THEN you can take the unit element of the group for S0. So if * is "+" then S0 could be 0. If * is "or" then S0 could be "false" etc. Now, take something else: let * be max, what would be the maximum of an empty array? Real'First? What would be then with the array invariant Max >= Min? What if Float is a subtype of a type which has lesser values than Real'First? -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de