The compiler for ALGOL W, on the Michigan Terminal System (MTS), at Newcastle University had some interesting quirks which I discovered by accident. The short story is that constants were actually variables allocated on the stack just like any other variable declared in the current block. Obviously, they were initialized to their value and you couldn't assign new values to them. Well, you could, but only by accident! I imagine that this approach (constants as specialized variables) made code generation easier.

As part of the explanation for how I discovered this I first have to digress into a short explanation of the way Newcastle had set up the MTS file system. Each line of the file was numbered starting at 1 and going on up. This is great when you know exactly what you're going to enter into your files. If, later, I wanted to insert a line between lines 1 and 2 I could do so and it would be given a line number of, I think, 1.3, but it might have been 1.6! It doesn't matter the exact value, what matters is that line numbers weren't necessarily integers! Except that they were! You could take the line number displayed when editing a file, multiply it by 1000 and get the integer line number associated with that line of the file. This whole approach avoided any need for renumbering files until you had the pressing need to, for example, insert a line between 1.234 and 1.235

I was writing some program and called a system level function (using the FORTRAN keyword even though I was calling an assembler function) to read a line 1 of a file. That worked fine, I got the line, but when I tried to eliminate the last character of the string I got an out of bounds error as index -973 didn't exist! Even more puzzling, if I tried the same thing in a different part of the program it worked just fine!

This error caused a little consternation as one of the systems programmers had been recently updating the compiler and it looked like I'd found a weird bug. He breathed a huge sigh of relief when he was able to track down the problem.

The call to the system function (remember it was called with the FORTRAN keyword) was, in essence, call by name with a "special" variable that was really the constant 1. The underlying routine had figured I didn't mean line 1, but line 1000 and had silently multiplied 1 by 1000 to get the line reference. Now, on returning to the ALGOL W program, the constant 1 had the value 1000 in that particular block. In outer blocks, the constant 1 still had the value 1.

End of anecdote that is a long way of saying constants were variable!