← Back to context

Comment by lisper

8 years ago

I use FST and RST (for FIRST and REST). I like them because they are short, mnemonic, and can be composed like CAR and CDR, e.g. CADADDR = FRFRRST (though I also believe that if you find yourself doing this you're almost certainly doing something wrong).

I think I prefer this as well. I think the importance of the mnemonic aspect can’t be overstated.. even though I did get _used_ to CAR and CDR, I feel like I was never immediately able to comprehend code that used them.. I had to always perform a mental translation as if I were somewhat bad at French or something and didn’t intuitively know the words.

It’s the same thing when I see test code that uses foo, bar, and baz as variables / strings instead of something more memorable like apple, banana, and cherry (or preferably something even more relevant to the code being tested). I feel like I have to work harder to understand what the tests are actually testing when I don’t have a good mental association with the variables under test. I get that it’s something programmers just do, but I’m really not a fan.

Maybe I’m an odd one though.

  • Another possibility is LHS and RHS for Left Hand Side and Right Hand Side (if you want to emphasize the use of a cons cell as a pair rather than a linked list).

    •     Date: 5 March 1980 08:54-EST
          From: Mark L. Miller <MILLER at MIT-AI>
          To:   Dave.Touretzky at CMU-10A, RWK
          cc:   KMP, HIC, BUG-LISP
          Re:   CAR and CDR
          
          Of course, you could rename them to, e.g., "LHS" and "RHS" for "Left Hand
          Side" and "Right Hand Side".  This would address the composition argument
          in favor of CAR and CDR: CADR -> LRHS (left-hand-side of right-hand-side),
          CDADADR -> RLRLRHS, and so on.   It's easy to provide these as macros.
          
          Later, you can explain that the original names are CAR and CDR, and isn't
          that silly, etc.
               Regards, Mark

      8 replies →

  • You're not the first person I've heard of that doesn't like foo,bar,baz nonce variable names. But it's the first I've heard of someone preferring meaningful but irrelevant words over meaningless words.

    In any case, I think it makes sense, even if it's not common within programming culture.