Aleksandar Donev wrote:
> ]
> An important consideration should also be whether there are
> side-effects, on both the argument and on the state of the machine.
> IMO, FUNCTIONs should not have side-effects, and also not depend on the
> state of the world (machine),
Well, it's not only your opinion, it's the modus operandi of the
Committee (as you note with your RANDOM_NUMBER example ;>).
But there's nothing in Standard to require it of user code, nor is it
terribly safe to assume people have coded that way (unless you see PURE
attached to the function ;>) Even then there are implementation
dependent ways to screw things up; but at least the programmer has
signaled their intent ;>
But OP was asking about efficiency and copying ... and as for the
arguments of a function they are treated just like the arguments of a
subroutine w.r.t. the Standard; implementations may vary, but I can't
recall one that does in any performance substantive way).
I would suggest that the OP should spend more time constructing
experiments and taking measurements and less time asking questions.
Learning is a "hands on" experience.
--
Keith H. Bierman [log in to unmask]
http://blogs.sun.com/khb
<speaking for myself, not Sun*> Copyright 2005
-------------------------------------------
|