Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!uwm.edu!gem.mps.ohio-state.edu!tut.cis.ohio-state.edu!ucbvax!pasteur!ames!skipper!elxsi!maine From: maine@elxsi.dfrf.nasa.gov (Richard Maine) Newsgroups: comp.lang.fortran Subject: Re: Type punning in FORTRAN (was in C) Message-ID: Date: 17 Oct 89 14:52:13 GMT References: <475@idacrd.UUCP> <1989Oct10.185851.6490@agate.berkeley.edu> <1131@mpx1.lanl.gov> <448@e-street.Morgan.COM> Sender: news@skipper.dfrf.nasa.gov Organization: NASA Dryden, Edwards, Cal. Lines: 53 In-reply-to: amull@Morgan.COM's message of 16 Oct 89 18:32:28 GMT In article <448@e-street.Morgan.COM> amull@Morgan.COM (Andrew P. Mullhaupt) writes: > Pardon me for asking, but is this TRANSFER a low level version of the APL > reshape primitive? EQUIVALENCE had this kind of effect, and it seems that > TRANSFER is getting another step closer to a kind of cross between reshape > and take. In previous postings I have advocated adopting the tamer APL > array manipulations in the array extensions for FORTRAN. This is another > case where I believe the various things TRANSFER could get up to should be > split (syntactically) between three different classes, two of which are APL > inspired: > 1. Reshaping. This is where the elements retain their values, but a vector > of ten elements can be made into, say, a five by two matrix. > 2. Taking. This is where an array of specified size is abstracted from an > existing matrix. For example, the upper left hand two by three matrix can > be taken from a ten by ten matrix. "Overtaking" a larger array from a > smaller array results (in APL) in filling by zeros. > 3. Casting. This is where the data is some floating representation which you > need to interpret as function pointers, (etc.). This use is the one under > discussion in this thread. > As some have pointed out, being able to cue the compiler, and other programmers > that casting is being done. I find it useful to have a syntactic representation > that distinguishes this from the other applications is helpful. > What is the real semantic interpretation of TRANSFER (Since I don't have time > to go through the Draft proposal, I don't know), and are there other new > facilities for Reshaping, and Taking? TRANSFER is a cast. The bits of the underlying representation are transferred without change. The shaping involved in transfer is not really the main point; it is needed mostly to handle types of different sizes (as in transferring a double precision scalar to an array of characters). True, you could use TRANSFER just for its reshaping, but that would be a bit of an "abuse". There is a separate function just for reshaping, called (strangely enough), RESHAPE. Taking sounds mostly like the 8x matrix section. If A is a 10x10 matrix, then A(1:2,1:2) is a 2x2 matrix taken from the upper left corner. However, you cannot extract a larger matrix from a smaller one, other than by writing it out as in REAL A(2,2),B(10,10) B = 0 B(1:2,1:2) = A -- Richard Maine maine@elxsi.dfrf.nasa.gov [130.134.1.1]