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-Thread: 103376,782d6c8a12248b09 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!64g2000hsu.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Ada Recursion with strings Date: Tue, 30 Sep 2008 17:28:46 -0700 (PDT) Organization: http://groups.google.com Message-ID: <8e3685ad-8a71-4912-a86d-746076215606@64g2000hsu.googlegroups.com> References: NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1222820926 30739 127.0.0.1 (1 Oct 2008 00:28:46 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 1 Oct 2008 00:28:46 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 64g2000hsu.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:7906 Date: 2008-09-30T17:28:46-07:00 List-Id: On Sep 30, 5:13 pm, Joe wrote: > On Sep 30, 6:24 pm, "Jeffrey R. Carter" > > wrote: > > Though you can refer to the function IP_String within itself as > > Ip_Packet.IP_String, it would be better to change the name of the parameter to > > something other than the name of the function, like Current_Result. > > doh, I didn't even see that. Changing the parameter name solved all > my problems. > > > How many times does the magic number 2 ** 8 appear in this short example? > > Thrice, I'm not sure I know what you're getting at. > > > There are other errors in your code; you'll probably figure several of > > them out once you get your program to run, and you'll probably figure > > another out if you change 123456 in your test to 65536. > > Thank you Adam for that little hint. The 2**8n numbers now work as > expected. > > One other thing. The image attribute returns a string with a space in > front. Is there any way to get rid of the space? The function Ada.Strings.Fixed.Trim (S, Ada.Strings.Both) will get rid of all leading and trailing spaces from S. I'd much prefer to have an 'Image attribute that didn't add that blank (it only adds it for nonnegative numbers). I'm not sure why the decision was made (back in Ada 83) to add the blank; having a formatted number with either a blank or a minus sign in front can help get numbers lined up in a report, but 'Image returns a variable-length string anyway so I don't think it could be used effectively to line anything up. This is one of the most annoying features of Ada, and I'm betting that I'm not alone in thinking that. -- Adam