I have a practical "best practice" question that is a consequence
of actual implementations. In the simple assignment
array = array_valued_function(...)
the semantics require the rhs to be fully evaluated before the
assignment is made. An obvious implementation is to generate
the rhs result in a temporary array and then copy that data into
the lhs array. Some time ago, I looked at the C output of the
NAG compiler, and came to the conclusion that (at least in some
cases) it was much smarter, in that it didn't actually move any
data; it simply switched internal pointers in the dope vector
that described the array. Whether this is typical of other
implementations too, I don't know. So this is a question for
those of you with inside knowledge of specific implementations;
in such cases is actual moving/copying of data avoided?
The issue I'm concerned about is of course efficiency: for such
simple assignments with large arrays in heavily used sections of
code, my gut feeling is that it is poor practice, because of all
the data movement, to use such a design. It would be much better
to provide a subroutine variant of the function in which the
array was passed as an argument and filled directly. Comments?
--
Neil Carlson <[log in to unmask]>
|