3 ms·
COBOL (or at least some of its dialects) has some really weird features I’ve never seen anywhere else. For example, only just the other day I learned that IBM m
by skissane 4y ago
COBOL (or at least some of its dialects) has some really weird features I’ve never seen anywhere else. For example, only just the other day I learned that IBM mainframe COBOL has a “REVERSED” clause on its OPEN statement, which opens an input file for reading backwards. Apparently it only works for fixed length record format files, and only for files stored on tape. It relies on the fact that the (non-SCSI) IBM mainframe tape command set has a “READ BACKWARDS” command which reads blocks off a tape in reverse order, by playing it backwards.
Back in the day, memory was very small, and hard disks were unavailable or very limited in capacity, so many COBOL programs used tapes as input, output, and temporary storage. OPEN INPUT REVERSED meant you could write out a temporary file to a tape, close it, and then immediately re-open it to start reading it back in (albeit backwards), without having to wait for the tape to rewind in between. It was particularly used to speed up external sorting algorithms (although those were more commonly done in assembler than COBOL, to maximise efficiency)
- jasomill 4y agoIBM 3590 and 3592 SCSI drives support the "READ REVERSE" SCSI command[1] which (in variable-block transfer mode) is equivalent to the "READ BACKWARD" channel command. For application details, see Knuth volume 3 [2], which even has a fold-out chart illustrating tape (and tape operator) movements involved in various sorting algorithms[3]. In brief, reading backwards allows you to use tape as a stack. [1] https://www.ibm.com/support/pages/system/files/inline-files/$FILE/3592%20SCSI%20Reference%20(EXTERNAL)_3.pdf#page=194 https://www.ibm.com/support/pages/system/files/inline-files/... [2] https://archive.org/details/B-001-001-250/page/299/mode/1up https://archive.org/details/B-001-001-250/page/299/mode/1up [3] https://archive.org/details/B-001-001-250/page/n356/mode/1up https://archive.org/details/B-001-001-250/page/n356/mode/1up