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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e38b3d31f83372db X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-05-29 16:23:55 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!logbridge.uoregon.edu!router1.news.adelphia.net!uunet!ash.uu.net!xyzzy!nntp From: Jeffrey Carter Subject: Re: Natural to String without space? (newbie question) X-Nntp-Posting-Host: e246420.msc.az.boeing.com Content-Type: text/plain; charset=us-ascii Message-ID: <3B142A29.EA1349A8@boeing.com> Sender: nntp@news.boeing.com (Boeing NNTP News Access) Content-Transfer-Encoding: 7bit Organization: The Boeing Company X-Accept-Language: en References: <3B0BD493.5ABBA12B@labe.felk.cvut.cz> <3B140ECD.A486A578@ftw.rsc.raytheon.com> Mime-Version: 1.0 Date: Tue, 29 May 2001 23:00:57 GMT X-Mailer: Mozilla 4.5 [en]C-CCK-MCD Boeing Kit (WinNT; U) Xref: archiver1.google.com comp.lang.ada:7860 Date: 2001-05-29T23:00:57+00:00 List-Id: Wes Groleau wrote: > > > function Image (N : in Natural) return String is > > N_Image : constant String := Natural'Image (N); > > begin > > return N_Image (2 .. N_Image'Last); > > end Image; > > Call me obsessive, but I feel safer with > > function Image (N : in Natural) return String is > N_Image : constant String := Natural'Image (N); > begin > return N_Image (N'Image'First + 1 .. > N_Image'Last ); > end Image; OK: You're obsessive. Actually, in the good old days (1984 or so) I used an Ada-83 compiler that implemented 'Image with different 'First than 1, despite ANSI/MIL-STD 1815A explicitly stating that it should be 1, so I tend to use something more like the 2nd example than the first (except I would use N_Image'First rather than N'Image'First). -- Jeffrey Carter