Structures
Eric S. Raymond
eric at snark.uu.net
Wed Mar 7 01:06:17 AEST 1990
In <1990Mar5.183244.1013 at utzoo.uucp> Henry Spencer wrote:
> The main motive for [structure-passing] is when you're essentially
> building your own data types (complex numbers in sci/eng number-crunching,
> two-dimensional coordinates in graphics, etc.) and want to treat them as
> if they were ordinary values. Passing pointers gets troublesome very
> quickly in such situations.
As usual, Henry is correct. However, speaking as a partisan of ADT design
techniques who likes to build entire program systems as collections of live
data types, I avoid passing structs anyhow. Pointers are significantly faster
to hand around and cheaper to store.
Of course this is not a problem if your type is int size or less. A struct
consisting of two short ints (useful in graphics work, for example) is an
excellent candidate to be passed around by value rather than by address.
--
Eric S. Raymond = eric at snark.uu.net (mad mastermind of TMN-Netnews)
More information about the Comp.lang.c
mailing list