Functions vs. parameters
Hi! I was hoping someone could save me some time before I go write
myself some code:
If I pass a parameter to a procedure, is it passed by value or by
reference (of course its transparent to us, but see next question)?
If I pass a parameter to a function, and the same parameter is returned
by that function, what is the overhead cost associated with it, i.e. am I
wasting time copying the object into memory? Is a copy of that object
actually sent? I would assume so, because if a function acts on a
parameter and doesn't return it, the original copy is unchanged.
Reason:
I am creating an include file and I am seriously considering treating the
include file as an object, i.e. all variables are scoped to the file, and the
"member" functions are the functions/procedures, where the global ones
are the "methods" of the object(file). If I do this, then all I need are
procedures to operate on the really, really big data structures that I
*was* previously passing to and returning from functions. Then I can
use functions to return the interesting parts of those structures to the
calling program. Now, the whole reason I am doing this is to try and cut
some time, but am I just totally pointing in the wrong direction here?
My whole idea is to avoid any overhead associated with passing a very
large structure back and forth from function to function.
I appreciate any information...
Thanks,
-Jay
|
Not Categorized, Please Help
|
|