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,ace9bff8eb84e5b1 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.germany.com!news-stu1.dfn.de!news.uni-stuttgart.de!not-for-mail From: Stefan Bellon Newsgroups: comp.lang.ada Subject: Re: Generic Zero Length Array Date: Fri, 22 Feb 2008 16:22:24 +0100 Organization: Comp.Center (RUS), U of Stuttgart, FRG Message-ID: <20080222162224.0b9e4ca8@cube.tz.axivion.com> References: <9b771018-fb0b-42eb-ae00-12ee3eda69b2@p43g2000hsc.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: infosun2.rus.uni-stuttgart.de 1203693786 12583 129.69.226.21 (22 Feb 2008 15:23:06 GMT) X-Complaints-To: news@news.uni-stuttgart.de NNTP-Posting-Date: Fri, 22 Feb 2008 15:23:06 +0000 (UTC) X-Newsreader: Sylpheed-Claws 2.6.0 (GTK+ 2.8.20; i486-pc-linux-gnu) X-URL: http://www.axivion.com/ Xref: g2news1.google.com comp.lang.ada:19974 Date: 2008-02-22T16:22:24+01:00 List-Id: On Fr, 22 Feb, shaunpatterson@gmail.com wrote: > if Error_Condition then > declare > type Result is new Element_List (Indexing.First + 1 .. > Indexing'First); > Result_String : Result; > begin > return Element_List (Result); > end; > end if; > > How do I initialize this array when I can't know what type it is or > will be? Funny, just yesterday I came across the code that did exactly this in our software: if List_Length = 0 then if Index_Type'Base'First = Index_Type'Base'Last then -- there seems to be no way to declare a null array -- for a `type Index_Type is (A)` raise Constraint_Error; else -- Workaround due to GNAT 6.0.2 bug (H221-018). return (Index_Type'Base'Last .. Index_Type'Base'Pred (Index_Type'Base'Last) => <>); end if; else -- non-empty case end if; And previously we had return (Index_Type'Base'Last .. Index_Type'Base'First => <>); written, which triggered H221-018, therefore we rewrote to use 'Pred. Greetings, Stefan -- Stefan Bellon