Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!mstan!amull From: amull@Morgan.COM (Andrew P. Mullhaupt) Newsgroups: comp.lang.fortran Subject: Re: Type punning in FORTRAN (was in C) Summary: TRANSFER considered possibly quite useful Message-ID: <448@e-street.Morgan.COM> Date: 16 Oct 89 18:32:28 GMT References: <475@idacrd.UUCP> <1989Oct10.185851.6490@agate.berkeley.edu> <1131@mpx1.lanl.gov> Organization: Morgan Stanley & Co. NY, NY Lines: 44 > If I read the June, 1989 draft F8X correctly, then the > new TRANSFER intrinsic function (p. 13-51, section 13.13.108) > will do precisely this. The syntax is > > result = TRANSFER(SOURCE, MOLD, SIZE) . > > It "returns a result with a physical representation identical to that > of SOURCE but interpreted with the type and type parameters of MOLD." > The last argument, SIZE, is optional and affects the array shape > of the result when SOURCE and MOLD have different sizes > (e.g., double precision and character). > > 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? Later, Andrew Mullhaupt