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.1 required=5.0 tests=AXB_XMAILER_MIMEOLE_OL_024C2, BAYES_00,MAILING_LIST_MULTI,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,228dbf2f126edf08 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-19 13:28:03 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!nycmny1-snf1.gtei.net!news.gtei.net!colt.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!fr.clara.net!heighliner.fr.clara.net!freenix!enst!enst.fr!not-for-mail From: "David C. Hoos, Sr." Newsgroups: comp.lang.ada Subject: Re: ADA and return functions (Strings) Date: Sun, 19 May 2002 15:27:29 -0500 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: References: <3ce75220@news.comindico.com.au> <5ee5b646.0205190630.237196b3@posting.google.com> Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1021840082 51214 137.194.161.2 (19 May 2002 20:28:02 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Sun, 19 May 2002 20:28:02 +0000 (UTC) Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.8 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:24383 Date: 2002-05-19T15:27:29-05:00 ----- Original Message ----- From: "Robert Dewar" Newsgroups: comp.lang.ada To: Sent: May 19, 2002 9:30 AM Subject: Re: ADA and return functions (Strings) > "David C. Hoos, Sr." wrote in message news:... > > > The best way to do this without spaces is something like this: > > > > return Ada.Strings.Fixed.Trim (Version.Major'img, Ada.Strings.Left) & > > "." & Ada.Strings.Fixed.Trim (Version.Minor'img, Ada.Strings.Left); > > Seems very heavy to drag in the whole of Ada.Strings.Fixed for such a trivial > task, and even heavier to call Trim repeatedly. Why not just write a little > function called Semsible_Image that you then call. Actually you can use the > name Image for this function. > After having pressed the "Send" button, I thought I had been a bit presumptuous to say "the best way ..."; Robert's comment about dragging in the whole of Ada.Strings.Fixed is certainly appropriate, if there were no other reason to drag it in. As far as the overhead of calling Trim twice is concerned, I reasoned that the function getVersion would likely be called only once, but certainly not frequently. This, too, is presumptuous, so I offer another implementation, perhaps not as (humanly) readable as my previous offering, but certainly more efficient: function getVersion return String is Major : constant string := Version.Major'img; Minor : constant string := Version.Minor'img; begin return Major (Major'First + 1 .. Major'Last) & "." & Minor (Minor'First + 1 .. Minor'Last); end; While we're looking at this function, I'll offer another comment. The use of verb phrases as the names of functions is not considered the best practice addording tho the Ada Style Guide. Instead function names should be noun phrases. So I would simply name this function Version.