comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison <dennison@escmail.orl.mmc.com>
Subject: Re: Efficient io of arbitrary binary data.
Date: 1996/09/17
Date: 1996-09-17T00:00:00+00:00	[thread overview]
Message-ID: <323ECE8F.FF6D5DF@escmail.orl.mmc.com> (raw)
In-Reply-To: 1996Sep14.112929.1@eisner


Brian Hanson wrote:
> 
>    Brian said
> 
>    "> I considering how this program could be written in Ada (part of
>    > an attempt to become Ada literate in an Ada hostile environment)
>    > I a puzzled.  The approaches which Ada seems to allow all require
>    > much more copying of data as I am not allowed to return a reference
>    > to a slice of an array I can only return the slice itself."
> 
> Robert Dewar writes:
>    Well seeing as you have neither slices nor references to slices in C,
>    it is hardly possible that this limitation is a significant one! DOn't
>    assume that because you are writing in Ada, you *have* to use all its
>    features!
> 
> C may not have slices but since a pointer to a char can be considered an
> a array, I have the equivalent to a slice by carrying around the length
> seperately.  I can use memcmp and memcpy to compare and move this block
> of data.  I would expect that most compilers turn these library calls
> into inline code.

The Ada equivalent to THAT would be passing around access types, and using
UNCHECKED_CONVERSION to hose the source object types into other access types
(assuming a typical implementation of access types - check your appendix F). 
This is, of course, to be avioded.

A slightly better method is to declare a "buffer" type which is an array
of byte (or integer, whatever's convienent)-sized objects. Eventually you 
will probably copy data out of your reciept buffer for client use. At THAT
point, do the UNCHECKED_CONVERSION. It won't be any extra code, if you are
already copying anyway.

-- 
T.E.D.          
                |  Work - mailto:dennison@escmail.orl.mmc.com  |
                |  Home - mailto:dennison@iag.net              |
                |  URL  - http://www.iag.net/~dennison         |




      parent reply	other threads:[~1996-09-17  0:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-09-13  0:00 Efficient io of arbitrary binary data Brian R. Hanson
1996-09-14  0:00 ` Larry Kilgallen
1996-09-16  0:00   ` Brian Hanson
1996-09-16  0:00     ` Stephen Leake
1996-09-16  0:00     ` Larry Kilgallen
1996-09-16  0:00     ` Robert A Duff
1996-09-14  0:00 ` Larry Kilgallen
1996-09-14  0:00   ` Robert Dewar
1996-09-16  0:00   ` Brian Hanson
1996-09-17  0:00   ` Ted Dennison [this message]
replies disabled

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