G
Good Guy
When it's the matter of deciding the best method of parameter passing
a series of complexities would be brought up to make the decision
about whether it is efficient for the argument to be passed by address
or value in machine code level and of course there might be several
dimensions of efficiency to be considered, so it would make sense for
this matter to be left up to compiler to decide about; with that said
I've come across a tip that is claimed to be a strict rule and if a
programmer follows the guideline of this tip the compiler can do its
job then to determine the best method for parameter passing, the tip
is always write function parameters associated with primitive types
(int, long, char, double, etc...), iterators and function objects
types (don't know if I missed anything more here), in the form of pass
by value and always write function parameters associated with any user-
defined type in the form of pass by reference to constant; now I'd
like to know if this rule is totally right and then if it is an
explanation of its philosophy is appreciated, but if there's anything
wrong with this rule what that is and why.
a series of complexities would be brought up to make the decision
about whether it is efficient for the argument to be passed by address
or value in machine code level and of course there might be several
dimensions of efficiency to be considered, so it would make sense for
this matter to be left up to compiler to decide about; with that said
I've come across a tip that is claimed to be a strict rule and if a
programmer follows the guideline of this tip the compiler can do its
job then to determine the best method for parameter passing, the tip
is always write function parameters associated with primitive types
(int, long, char, double, etc...), iterators and function objects
types (don't know if I missed anything more here), in the form of pass
by value and always write function parameters associated with any user-
defined type in the form of pass by reference to constant; now I'd
like to know if this rule is totally right and then if it is an
explanation of its philosophy is appreciated, but if there's anything
wrong with this rule what that is and why.