There are certain languages which are still in use, are still changing and maturing, and yet are also frozen in time. Fortran is a perfect example- over the past 40–60 years, huge piles of code, mostly for scientific and engineering applications, was written. It may be hard to believe, but modern Fortran supports object-oriented programming and has a focus on concurrency.
Most of the people using Fortran, it seems, learned it in the 70s. And no matter what happens to the language, they still write code like it’s the 70s. Fortran’s own seeming immortality has imbued its users with necromantic energy, turning them into undying, and unchanging Liches.
Which brings us to Greg. Greg works with an engineer. This engineer, the Dark Lich Thraubagh, has a personal “spellbook” containing snippets of Fortran they’ve picked up over the past 40 years. For example, there’s this block, which creates an array of every number from 1–999, padded out to three characters.
I don’t know Fortran, so I give credit to this engineer/lich for writing code which even I can understand why it’s wrong and bad.
character*3 c(999)
character*1 b(9)
b(0)='0'
b(1)='1'
b(2)='2'
b(3)='3'
b(4)='4'
b(5)='5'
b(6)='6'
b(7)='7'
b(8)='8'
b(9)='9'
do 1 i=1,999
c(i)(3:3)=b( int( 10*((i/10.0)-int(i/10.0) ) ) )
c(i)(2:2)=b( int( 10*((i/100.0)-int(i/100.0) ) ) )
c(i)(1:1)=b( int( 10*((i/1000.0)-int(i/1000.0) ) ) )
1 continue
Start by creating a 1000-element array of 3-character long strings. Then create a 10-element array of 1-character long strings, containing the numbers 0–9.
Then we loop, and populate the strings in that larger array by doing some modular arithmetic and selecting from the 10-element array.
Fun fact: even in Fortran 77, there were a number of formatting options. If, for example, you wanted to put a number into a padded string, you could do write(string_var,"I3.3") 99
. string_var
now contains "099"
. Maybe not the clearest thing, but much simpler, certainly.
Funner fact: the c
array was basically not used anywhere, in the particular program which caused Greg to send this along. The Dark Lich Thraubagh simply copies their “spellbook” into every program they write, gradually adding new methods to the spellbook, but never updating or modifying the old. They’ve been doing this for 40 years, and plan to do it for at least a century more.