Address of array

aglew at ccvaxa.UUCP aglew at ccvaxa.UUCP
Tue Apr 1 03:13:00 AEST 1986


struct and array pass-by-value and return - a moderate view:
Structures should always be passed by reference. Usually you only need
to look at fields, and if you need scratch space then you should declare
local variables. (Modify this for structs that fit in small packages,
like struct { short x,y; }).

However, being able to return structs without having to worry about allocating
space is a great convenience. Actually, what is needed is return of pointers,
with a convenient way of automatically allocating space for the struct that
you're going to point to. This way you get convenience and the efficiency
of not having all those extra copies to and from the stack. Doesn't everybody
use a `statalloc' package for this type of thing?

Structure and array assignment, and comparison for equality, without buffer
copies is a good thing.



More information about the Comp.lang.c mailing list