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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham 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!uio.no!news-FFM2.ecrc.net!news.iks-jena.de!not-for-mail From: Lutz Donnerhacke Newsgroups: comp.lang.ada Subject: Re: Surprise in array concatenation Date: Thu, 1 Sep 2005 12:02:09 +0000 (UTC) Organization: IKS GmbH Jena Message-ID: References: <1125544603.561847.32140@g47g2000cwa.googlegroups.com> <14muavojz308w.1ouv7xin79rqu$.dlg@40tude.net> <87fyspgqrm.fsf@mid.deneb.enyo.de> <4316ea4d$0$24155$9b4e6d93@newsread4.arcor-online.net> NNTP-Posting-Host: taranis.iks-jena.de X-Trace: branwen.iks-jena.de 1125576129 29227 2001:4bd8:0:666:280:adff:fe1e:79ba (1 Sep 2005 12:02:09 GMT) X-Complaints-To: usenet@iks-jena.de NNTP-Posting-Date: Thu, 1 Sep 2005 12:02:09 +0000 (UTC) User-Agent: slrn/0.9.8.0 (Linux) Xref: g2news1.google.com comp.lang.ada:4366 Date: 2005-09-01T12:02:09+00:00 List-Id: * Georg Bauhaus wrote: > Florian Weimer wrote: >> Even more problematic is the empty array whose index type >> is an enumeration type with just one enumeration literal. > > This looks like a formalist's problem to me. Use subtypes: > > type With_Off is (Off, Only); -- two literals > subtype The_King is With_Off range Only .. Only; -- one literal You formally introduces a base type. But even this subtype fails to construct an empty array starting on Off. Without the base type an empty array can't specified: 1 with Ada.Text_IO; 2 use Ada.Text_IO; 3 4 procedure t is 5 type Offset is (Single); 6 type Test_Array is array (Offset range <>) of Integer; 7 empty : Test_Array(Offset'First .. Offset'Base'Pred(Offset'First)); 8 begin 9 Put_Line("empty'First = " & Offset'Image(empty'First)); 10 Put_Line("empty'Last = " & Offset'Image(empty'Last)); 11 end; gcc -c t.adb t.adb:7:49: Pred of "Offset'First" t.adb:7:49: static expression raises "Constraint_Error" gnatmake: "t.adb" compilation error