geiser@apollo.UUCP (01/23/87)
(Chuck McManis @ Sun Microsystems, Inc.) writes: >Of course there was a time when you could right a Fortran program for >TOPS-10 like so : > > FOO(0.0,10) > > SUBROUTINE FOO(A,B) > A = B * 3 > RETURN > END >And when executed the compiler generated constant for zero was a pointer >to some known word with zero in it was changed. This affected all subsequent >references to the constant 0.0 by your program or anyone elses on the >system! > >-- >--Chuck McManis >uucp: {anywhere}!sun!cmcmanis BIX: cmcmanis ARPAnet: cmcmanis@sun.com >These opinions are my own and no one elses, but you knew that didn't you. Have you tried this program on any of your own equipment? Both Sun2's and Sun3's allow you to do this. The code produced is slightly different for each, though. For example: PROGRAM MAIN CALL SUBR(1,2,3) CALL SUBR(1,2,3) END SUBROUTINE SUBR(I,J,K) WRITE(6,*) I I = 3 RETURN END The results produced by this code are: Sun3: ===== 1 3 Sun2: ===== 1 3 2 3 In the Sun3 case, constants are pooled by procedure and therefore only the constant for the main program gets changed. In the Sun2 case constants are pooled for the whole program. When the IO routine gets called the second time, it's told to print 1 value, 1 is now 3 and it prints the next two constants (memory locations) as well. I would say this is a rather intriguing way to control output of arrays, etc. You no longer have to put in those tedious implied DO-lists. Just change the constant 1 to however many elements of the array you'd like to print before the IO statement and change it back after you're done. Neat, huh? And just think of the job security benefit! :-) (Sorry, I couldn't resist.) Wayne Geiser Apollo Computer, Inc. {wanginst, yale, uw-beaver, brunix, utah-cs}!apollo!geiser