Why pass structs? (not struct pointe

herndon at umn-cs.UUCP herndon at umn-cs.UUCP
Mon Mar 2 10:49:00 AEST 1987

  Maybe my argument will be silly too, but the arguments that
I have seen so far strike me as hilarious.
  As far as I can figure, no operation in original C ever did
anything that incurred non-obvious costs in either space or time.
By significant, I mean such as scanning an object of large size,
allocating space for a pass-by-value array, etc.  The user, if
he needed to copy a structure or allocate a large array, was
forced to do this himself, *explicitly*.  Where C did allocate
space for large objects, the declaration was apparent, e.g.,
"struct foo bletch[10000];".
  This is convenient for those who write performance sensitive
code -- no innocent looking statement is going to chew up megabytes
and megacycles of resources.
  In today's enlightened world, however, programmer convenience
is more heavily stressed, and if the user wants it, the user gets
it.  My personal opinion is that this is the correct choice.
I have, however, on many occasions, in a production environment,
seen otherwise competent programmers wondering in disbelief at
their programs when they get run-time errors from procedures
that pass LARGE parameters by value on machines with memories
only somewhat bigger than the parameters.
  It still amazes me how little some "professional programmers"
understand "high-level language" compilers.

More information about the Comp.lang.c mailing list