From: Peter Dulimov <pedu@eraseme.systems.saab.se>
Subject: Re: Hi byte and Lo Byte Question
Date: Fri, 24 Aug 2001 10:09:59 +0200
Date: 2001-08-24T10:09:59+02:00 [thread overview]
Message-ID: <3B860BD6.7A1A8EA3@eraseme.systems.saab.se> (raw)
In-Reply-To: 9m34r7$6ka$1@nh.pace.co.uk
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.
Cheers,
Peter Dulimov.
Marin David Condic wrote:
[snip - stuff deleted]
> Here's a proposition worth discussing:
>
> In a lot of embedded apps and/or other apps that need to deal with things
> like communication streams, it would be very handy to be able to easily
> translate whatever data you have into raw bytes or turn raw bytes into the
> data you want. You typically need to do this efficiently and don't want to
> move the data. You can certainly get there with Unchecked_Conversion, but
> this can be a pain in the ASCII and might be inefficient - requiring the
> data to be moved. You can also get there by laboriously creating your own
> overlays - but this can rewuire a lot of declaring if you have a lot of
> things you want to treat as raw bytes.
>
> 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 ;
>
> Maybe it should be an attribute of an Object rather than a Type? Don't know
> what can be done about safety in the event that the sizes don't line up, but
> I'll leave that to the compiler guys.
>
> I'm not fussy about the details (like the names) but it sure would be nice
> to have a means of very easily, efficiently and quickly treating any object
> as a stream of bytes - with the caveat being that I've just removed the
> safety net (as with Unchecked_Conversion) and I can now royally shoot myself
> in the foot.
>
> Comments?
>
> MDC
next prev parent reply other threads:[~2001-08-24 8:09 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 [this message]
2001-08-24 16:20 ` Warren W. Gay VE3WWG
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