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,4e9860765413318c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-24 09:20:32 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.direct.ca!look.ca!news1.tor.metronet.ca!nnrp1.tor.metronet.ca!not-for-mail Message-ID: <3B867ECA.80502@home.com> From: "Warren W. Gay VE3WWG" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.2) Gecko/20010726 Netscape6/6.1 X-Accept-Language: en-us MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Hi byte and Lo Byte Question References: <9m0gn6$b6j$1@zeus.orl.lmco.com> <3B843C0C.9A3282B@raytheon.com> <9m34r7$6ka$1@nh.pace.co.uk> <3B860BD6.7A1A8EA3@eraseme.systems.saab.se> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 24 Aug 2001 16:20:27 GMT NNTP-Posting-Host: 198.96.47.195 NNTP-Posting-Date: Fri, 24 Aug 2001 10:20:27 MDT Organization: MetroNet Communications Group Inc. Xref: archiver1.google.com comp.lang.ada:12384 Date: 2001-08-24T16:20:27+00:00 List-Id: Peter Dulimov wrote: > This is a really good idea. > I have spent a lot of time doing this manually, and inefficiently (in terms of > produced code, as well as the speed at which I produce it), in Ada83 (so not > even modular types available.) > Also, the original poster's problem --- switching byte order --- becomes easy. ... >>What about an attribute of any type that yields an array of >>Ada.Streams.Stream_Element_Array ? Similarly, going in the other direction: >> >>for X in My_Type'Raw_Data (My_Data)'Range loop >> Some_Storage_Element := My_Type'Raw_Data (My_Data) (X) ; >>end loop ; >> >>or >> >>Some_Field := My_Type'Overlay (Some_Stream_Element_Array).Other_Field ; ... >>Comments? I see where you're going on the "efficiency" argument, but ignoring that for a moment, what about a different approach.. Someone could craft an Ada subset (declaration) language, that is compiled by a small compiler (like a CORBA IDL compiler), and generates a resulting package body and spec, in existing Ada95 terms to accomplish what you want. A better way might be to use ASIS with the necessary "code" added to generate your packages (some commercial venture has probably already done this at some point). Of course, the draw back to this approach is that you don't avoid the data copying that would be required by the generated code. The advantage however, would be to keep the language from growing in size. If you look at: >>for X in My_Type'Raw_Data (My_Data)'Range loop >> Some_Storage_Element := My_Type'Raw_Data (My_Data) (X) ; >>end loop ; there is some data copying on a Some_Storage_Element basis anyway. Unless Ada0Y were to gain endian representation features, I think a certain amount of copying (internal or external) would be necessary anyway. But I have to admit, that a representation clause for endianess would be extremely convenient. Then at least the compiler can do it in the most effective manner for the platform it was compiled on. -- Warren W. Gay VE3WWG http://members.home.net/ve3wwg