Parametric polymorphism: Difference between revisions
m
→{{header|Fortran}}
Line 472:
This is because consecutive elements in an array are expected to occupy consecutive locations in storage, but the CODE elements do not, being separated by the other elements of the aggregate. So, the compiler generates code to copy the required elements to a work area, presents that as the actual parameter, and copies from the work area back on return from the function, thereby vitiating the speed advantages of the binary search. This is why the <code>INTENT(IN)</code> might help in such situations, as will writing <code>FIND(x,TABLE(1:N).CODE,N)</code> should N be often less than the full size of the table. But really, in-line code for each such usage is the only answer, despite the lack of a pre-processor to generate it.
Other options are to remain with the older-style of Fortran,
In short, the available polymorphism whereby a parameter can be a normal array, or, an array-like "selection" of a component from an array of compound entities enables appealing syntax, but disasterous performance.
|