comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Generic Zero Length Array
Date: Fri, 22 Feb 2008 13:25:07 -0600
Date: 2008-02-22T13:25:07-06:00	[thread overview]
Message-ID: <fpn966$k22$1@jacob-sparre.dk> (raw)
In-Reply-To: 2446841a-8bb0-46bc-94ed-099e4e0ca74c@k2g2000hse.googlegroups.com

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1185 bytes --]

"Egil H�vik" <egilhovik@hotmail.com> 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





  parent reply	other threads:[~2008-02-22 19:25 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-22 13:31 Generic Zero Length Array shaunpatterson
2008-02-22 13:53 ` Egil Høvik
2008-02-22 13:55   ` shaunpatterson
2008-02-22 14:11     ` Georg Bauhaus
2008-02-22 19:25   ` Randy Brukardt
2008-02-22 23:01     ` Adam Beneschan
2008-02-23  9:30       ` Dmitry A. Kazakov
2008-02-23 14:27       ` Robert A Duff
2008-02-23 16:16         ` Dmitry A. Kazakov
2008-02-25 16:41         ` Adam Beneschan
2008-02-25 19:14           ` Robert A Duff
2008-02-22 19:25   ` Randy Brukardt [this message]
2008-02-22 19:25   ` Randy Brukardt
2008-02-22 14:23 ` Stefan Lucks
2008-02-22 16:52   ` Adam Beneschan
2008-02-22 14:26 ` Robert A Duff
2008-02-22 15:22 ` Stefan Bellon
2008-02-22 23:03   ` Adam Beneschan
2008-02-23 10:19     ` Stefan Bellon
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox