Returning several values (was Re: The D programming language)

Richard Harter g-rh at cca.CCA.COM
Thu Mar 10 08:25:38 AEST 1988


In article <12206 at brl-adm.ARPA> GAY%CLSEPF51.BITNET at CUNYVM.CUNY.EDU writes:

	... basically saying to use a struct to hold the return values.

Yeah, sometimes this is exactly what you want to do.  There are a couple
of catches.  The first is that the returned values may not naturally go
into a structure in the calling program.  The second is that you now have
to communicate the declaration of the structure between the two routines;
okay, sortof, if they are in the same file, not so okay if they are in
different files.  Since all good little programmers avoid replicating
declarations like the plague, you put the temporary structure definition
in an include file.  In a large program you end up with a lot of these
yucky little include files, or clump them in a big include file with all
that says about data coupling.  As a practical matter, in C as it stands,
my experience says that it's better to bite the bullet and pass pointers,
doing call by reference by hand -- the code maintenance problems are less.
-- 

In the fields of Hell where the grass grows high
Are the graves of dreams allowed to die.
	Richard Harter, SMDS  Inc.



More information about the Comp.lang.c mailing list