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.1 required=5.0 tests=BAYES_00, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ace9bff8eb84e5b1 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news2.google.com!news.glorb.com!feeder.erje.net!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Generic Zero Length Array Date: Fri, 22 Feb 2008 13:25:07 -0600 Organization: Jacob's private Usenet server Message-ID: References: <9b771018-fb0b-42eb-ae00-12ee3eda69b2@p43g2000hsc.googlegroups.com> <2446841a-8bb0-46bc-94ed-099e4e0ca74c@k2g2000hse.googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: jacob-sparre.dk 1203709958 20546 69.95.181.76 (22 Feb 2008 19:52:38 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Fri, 22 Feb 2008 19:52:38 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1914 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1914 Xref: g2news1.google.com comp.lang.ada:19988 Date: 2008-02-22T13:25:07-06:00 List-Id: "Egil H�vik" wrote in message news:2446841a-8bb0-46bc-94ed-099e4e0ca74c@k2g2000hse.googlegroups.com... >On Feb 22, 2:31 pm, shaunpatter...@gmail.com wrote: >> I have a bit of legacy code in my system that I am trying to remove >> all warnings from. >> >> The package is a generic -- with: >> >> type Element is (<>); >> type Element_List is array (Indexing range <>) of Element; >> >> I have been stumped by one compiler warning where one of the functions >> needs to return a zero-length empty generic array: ... >A new generic parameter Null_Element would do the trick, but >that means changing code wherever the generic is used... > >type Element is (<>); >type Element_List is array (Indexing range <>) of Element; >Null_Element : Element; > >then you could rewrite the above code to > >if Error_Condition then > return Element_List'(Indexing'First..Indexing'First-1 => Null_Element); >end if; If you are not limited to Ada 95, you can use the <> here, and then you don't need the extra generic parameter: if Error_Condition then return Element_List'(Indexing'First..Indexing'First-1 => <>); end if; Randy. -- ~egilhh