Spam (madbodger) wrote,

  • Location:
  • Mood:
  • Music:
While reading a book on Perl, I realized something about ForTran. Of course, I may be wrong, but I think I'm right. In ForTran, a statement like this is valid:

4 = 3

After executing that statement if you use 4 for something, it has the value of 3. People explained this to me, with much giggling, saying ForTran would let you change the value of 4. I now suspect this isn't strictly true (for one thing, 41 still has the expected value). I think this is just an instance of ForTran's habit of creating variables whenever something is referenced as a variable. If you call COLOR(MAGENT) by mistake when trying to set the color to magenta, and your program doesn't have a variable named MAGENT, ForTran will helpfully create a variable by that name, and initialize it to zero for you. A variant of that happened to me once while programming a Silicon Graphics machine, due to the fact that some of the code had been compiled on a version of ForTran that truncated variable names to six characters. As zero equated to black, my lovely double-buffered rotating 3-D Gouraud shaded figures were completely invisible.

But I digress.

What's really happening in the 4 = 3 statement is that ForTran sees me using the symbol 4 as a variable. It obediently creates a variable named "4" and assigns it a value of 3. Then, when you refer to 4, you get that variable, which shadows the original integer 4.

When I was little, my mom (who was a math teacher) instilled in me the differences between numbers, digits, and chalk dust. These differences are subtle but real, and occasionally come up and bite the unwary. When I got into typography, and added concepts of letters, characters, and glyphs, they fit right into the pantheon.

Tags: fortran, programming
  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic