Hollerith constantHollerith constants, named in honor of Herman Hollerith, were used in early FORTRAN programs to allow manipulation of character data. Early FORTRAN had no MechanicsBy the FORTRAN 66 Standard, Hollerith syntax was allowed in the following uses:
Portability was problematic with Hollerith constants. First, word sizes varied on different computer systems, so the number of characters that could be placed in each data item likewise varied. Implementations varied from as few as two to as many as ten characters per word. Second, it was difficult to manipulate individual characters within a word in a portable fashion. This led to a great deal of shifting and masking code using non-standard, vendor-specific, features. The fact that character sets varied between machines also complicated the issue. Some authors were of the opinion that for best portability, only a single character should be used per data item. However considering the small memory sizes of machines of the day, this technique was considered extremely wasteful. Technological obsolescenceOne of the major features of FORTRAN 77 was the Hollerith constants were removed from the FORTRAN 77 Standard, though still described in an appendix for those wishing to continue support. Hollerith edit descriptors were allowed through Fortran 90, and were removed from the Fortran 95 Standard. ExamplesThe following is a FORTRAN 66 hello world program using Hollerith constants. It assumes that at least four characters per word are supported by the implementation: PROGRAM HELLO1
C
INTEGER IHWSTR(3)
DATA IHWSTR/4HHELL,4HO WO,3HRLD/
C
WRITE (6,100) IHWSTR
STOP
100 FORMAT (3A4)
END
Besides PROGRAM HELLO2 CALL WRTOUT (11HHELLO WORLD, 11) STOP END C SUBROUTINE WRTOUT (IARRAY, NCHRS) C INTEGER IARRAY(1)[notes 1] INTEGER NCHRS C INTEGER ICPW DATA ICPW/4/[notes 2] INTEGER I, NWRDS C NWRDS = (NCHRS + ICPW - 1) /ICPW WRITE (6,100) (IARRAY(I), I=1,NWRDS) RETURN 100 FORMAT (100A4)[notes 3] END Although technically not a Hollerith constant, the same Hollerith syntax was allowed as an edit descriptor in PROGRAM HELLO3
WRITE (6,100)
STOP
100 FORMAT (11HHELLO WORLD)
END
One of the most surprising features was the behaviour of Hollerith edit descriptors when used for input. The following program would change at run time PROGRAM WHAT1
READ (5,100)
WRITE (6,100)
STOP
100 FORMAT (11HHELLO WORLD)
END
Notes
References
|