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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4e2dfdc3b0f2775d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-23 07:10:46 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!logbridge.uoregon.edu!titan03.ksc.nasa.gov!niven.ksc.nasa.gov!usenet From: "Samuel T. Harris" Newsgroups: comp.lang.ada Subject: Re: Stream_Element_Array and an empty array Date: Thu, 23 Aug 2001 09:02:17 -0500 Organization: Raytheon Aerospace Engineering Services Message-ID: <3B850CE9.DCC6533D@gsde.hou.us.ray.com> References: <3B83C03F.8F1A6357@gsde.hou.us.ray.com> <3B84C0DE.79F20395@amsjv.com> Reply-To: samuel_t_harris@raytheon.com NNTP-Posting-Host: sstf-fw.jsc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.7 [en] (X11; U; IRIX64 6.2 IP19) X-Accept-Language: en Xref: archiver1.google.com comp.lang.ada:12327 Date: 2001-08-23T09:02:17-05:00 List-Id: Philip Anderson wrote: > > "Samuel T. Harris" wrote: > > > > > Given that in the above text A is a variable, > > no assignment is necesary. If you must have > > an assignment, or an initial expression > > because it is constant, then you can > > do the following ... > > > > nil : constant stream_element_array (1..0) := (others => 0); > > ... > > a := nil; > > That must the clearest Ada way of obtaining a zero-length array of a > particular type; declare an example and give it a suitable name (Nil, > Empty_Array, Zero_Length_Array, whatever), since the result of this > particular Ada idiom is easier to understand given this clue. It then > becomes obvious what you are doing when you pass it as a parameter. > Thanks for that. For years (decades) I have made is a habit to always define a nil constant for any interesting type. Even my record types, whose every field declaration has a default initial expression, also gets a nil_type constant. Along those lines, I also define width, image, and value functions so I get easy instrumentation or I/O facilities nearly for free. -- Samuel T. Harris, Senior Software Engineer II Raytheon, Aerospace Engineering Services "If you can make it, We can fake it!"