From: brh@poplar111.cray.com (Brian Hanson)
Subject: Re: Efficient io of arbitrary binary data.
Date: 1996/09/16
Date: 1996-09-16T00:00:00+00:00 [thread overview]
Message-ID: <BRH.96Sep16000330@poplar111.cray.com> (raw)
In-Reply-To: 1996Sep14.112929.1@eisner
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.
I had hopes of packaging up the buffer management code so that the sort
code just dealt with string references. A language that I used for many
years (cybil - a descendent of pascal used as a system language on the
Control Data 180 NOS/ve systems) provided two usefull abstractions - the
heap and sequence. The heap was used to provide a capability vaguely
similar to Ada's storage pools. Sequences provided a way to access a
block of memory in a way that did not violate type checking. References
to objects could be "next"ed from the heap stack like. In, cybil,
writing this sort program would be very straight forward with the full
assistance of the compiler. It is my experience with cybil that
attracts me to Ada and makes writing c painful.
So the question is not whether I can translate the code line for line
from c to Ada generating a c program in Ada but what are the Ada
idioms for dealing with this sort of program?
Brian Hanson
--
-- Brian Hanson
-- brh@cray.com
next prev parent reply other threads:[~1996-09-16 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-14 0:00 ` Robert Dewar
1996-09-16 0:00 ` Brian Hanson [this message]
1996-09-17 0:00 ` Ted Dennison
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 ` Robert A Duff
1996-09-16 0:00 ` Larry Kilgallen
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox