Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!rpi!sci.ccny.cuny.edu!phri!cmcl2!lanl!jlg From: jlg@lanl.gov (Jim Giles) Newsgroups: comp.lang.fortran Subject: Re: Education for Fortran 90 Message-ID: <63474@lanl.gov> Date: 19 Sep 90 21:37:03 GMT References: <1990Sep18.144822.2854@csc.anu.oz.au> Organization: Los Alamos Natl Lab, Los Alamos, N.M. Lines: 52 From article <1990Sep18.144822.2854@csc.anu.oz.au>, by myb100@csc.anu.oz.au: > [...] > Pardon my ignorance - but what do you mean by 'pointers to array sections' ? > > Am I wrong in guessing (probably, yes :-) ) that these are the addresses > where a particular section (say a row/column, can't remember which) of an > array starts ? If this is the case I can suggest something useful for them. You are probably lucky not to know what they are and I am somewhat reluctant to explain something to you which you will not really ever want to use. But, here goes anyway. Here is one of the examples given in the June 1990 version of the Fortran 90 proposal: EVERY_OTHER => VECTOR(1:N:2) where both VECTOR is a one-d array with the TARGET attribute, and EVERY_OTHER was declared as a one-d POINTER. After the execution of the above statement, a reference to EVERY_OTHER is exactly the same as if you wrote VECTOR(1:N:2). So, for example: EVERY_OTHER = 0.0 VECTOR(1:N:2) = 0.0 These statements have exactly the same meaning (zero every other element of VECTOR). The so-called POINTER is actually a full descriptor of an array - with extent, rank, and stride attributes. The problem arises in the following manner: EVERY_OTHER_PRIME => OTHER_VECTOR(1:N:2) This statement assigns another pointer similar to the first, but to a different array with the same bounds. So the following now occurs: EVERY_OTHER = EVERY_OTHER_PRIME VECTOR(1:N:2) = OTHER_VECTOR(1:N:2) You might expect these two statements to have the same meaning - and semantically they do. But, the compiler would have to do some quite sophisticated checking to determine whether the two pointers were aliased or not - even so, it might be unable to determine that they aren't (if they are dummy arguments, for example). Even a simple compiler can tell that the second statement contains no aliasing (unless the two vectors are EQUIVALENCED locally). So the compiler is likely to generate _very_ much more efficient code for the second statement. For this reason (and this is a simple example - real cases would be even more likely to cause problems) the user would naturally prefer to use the second notation everywhere. So, why is the pointer-to-section feature in the standard at all? J. Giles