comp.lang.ada
 help / color / mirror / Atom feed
From: "Warren W. Gay VE3WWG" <ve3wwg@home.com>
Subject: Re: Hi byte and Lo Byte Question
Date: Fri, 24 Aug 2001 16:20:27 GMT
Date: 2001-08-24T16:20:27+00:00	[thread overview]
Message-ID: <3B867ECA.80502@home.com> (raw)
In-Reply-To: 3B860BD6.7A1A8EA3@eraseme.systems.saab.se

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




  reply	other threads:[~2001-08-24 16:20 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-22 14:48 Hi byte and Lo Byte Question mop
2001-08-22 15:56 ` Larry Kilgallen
2001-08-22 16:21 ` Ted Dennison
2001-08-22 23:11 ` Mark Johnson
2001-08-23  0:23   ` Darren New
2001-08-23 14:13     ` Mark Johnson
2001-08-23 17:15       ` Darren New
2001-08-24  0:00       ` Robert Dewar
2001-08-24  7:52         ` Martin Dowie
2001-08-23 14:43   ` Marin David Condic
2001-08-24  8:09     ` Peter Dulimov
2001-08-24 16:20       ` Warren W. Gay VE3WWG [this message]
2001-08-24 17:05         ` Marin David Condic
2001-08-24 17:46           ` Warren W. Gay VE3WWG
2001-08-25  7:15             ` Simon Wright
2001-08-27 16:33               ` Warren W. Gay VE3WWG
2001-08-23  1:26 ` DuckE
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox