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,f3514db0a21f9b44 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,UTF8 Path: g2news2.google.com!news4.google.com!feeder.news-service.com!188.40.43.213.MISMATCH!feeder.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Hexadecimal and stream element arrays Date: Mon, 19 Apr 2010 22:52:42 +0200 Organization: A noiseless patient Spider Message-ID: <87aasz2mhx.fsf@ludovic-brenta.org> References: <2f4313a5-bb3d-4f7f-8a86-7c8f7d549c53@k41g2000yqf.googlegroups.com> <90efa5d2-a438-451b-8eb6-0e913b4200ca@x12g2000yqx.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Mon, 19 Apr 2010 20:52:43 +0000 (UTC) Injection-Info: feeder.eternal-september.org; posting-host="W8c2PZ3nqsYZZWY5/Jpl9A"; logging-data="22150"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/rLv2zon0G1ARx9HCQocKR" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:78uRJ0Mo3femeL4aWMHrWw0POc0= sha1:l/Gna92IP5PBqXK8vFTehGu6h3I= Xref: g2news2.google.com comp.lang.ada:11050 Date: 2010-04-19T22:52:42+02:00 List-Id: "Jeffrey R. Carter" writes: > On Apr 19, 9:24 am, Ludovic Brenta wrote: >> >> If you want to avoid the 16## part, you can easily convert the >> stream_elements to a string representation yourself like so: >> >> function To_Hex (E : in Ada.Streams.Stream_Element) return String is > > This seems unnecessarily complex to me. Using the standard library to > put an element to a String in base 16, then stripping the "16#" from > the front and '#' from the end seems simpler, clearer, and less error > prone. I find it funny you should say that because I thought exactly the opposite: letting Ada.Text_IO (which is notoriously slow) do the conversion to string and then doing string manipulation is less clear and more error-prone, IMHO (a proper implementation would use a simple, but full-fledged, finite state machine). But your approach is certainly valid and correct nevertheless. -- Ludovic Brenta.