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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7402728c011ea87a X-Google-Attributes: gid103376,public From: brh@poplar111.cray.com (Brian Hanson) Subject: Re: Efficient io of arbitrary binary data. Date: 1996/09/16 Message-ID: #1/1 X-Deja-AN: 180844339 references: <3239B3B2.1AE4@cray.com> <1996Sep14.112929.1@eisner> organization: Cray Research a division of Silicon Graphics, Inc. newsgroups: comp.lang.ada Date: 1996-09-16T00:00:00+00:00 List-Id: 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