Blogging Ottinger (tim)

2008-September-3

Lower Case L Variables Spotted

Filed under: Angst, Programming

Arrrgh!

You should NEVER use the lower-case L as a variable name. Ever. Especially if you’re going to have it in proximity to a 1 (which is a one, a fact that I have to call out because it looks like the l, which is an L). Ever. Never ever ever. Even in Python, which is one of the most readable languages in the world when it’s done correctly.

   2  def perm(l):
   3      sz = len(l)
   4      if sz < = 1:
   5          return [l]
   6      return [p[:i]+[l[0]]+p[i:] for i in xrange(sz) for p in perm(l[1:])]

The algorithm/snippet is okay, other than the choice of variable names, with is quite dreadful all the way through.

URL withheld to protect the butthead.

2 Comments »

The URI to TrackBack this entry is: http://tottinge.blogsome.com/2008/09/03/lower-case-l-variables-spotted/trackback/

  1. Unless the purpose of the variable is to represent a “line,” in which case it’s a really good mnemonic because it looks like a line. What’s not to love?

    Comment by Darrin Thompson — 2008-September-3 @ 04:37

  2. Ooo, maybe we can mix 1, l, |, and I liberally in code. It would be a language like BF in too many ways. Maybe call it the “tall men” language. A snippet of code:

    |1!!l||1|I*ll1.l1|.I1l!|

    Comment by Tim — 2008-September-4 @ 01:49

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>



Anti-spam measure: please retype the above text into the box provided.

Get free blog up and running in minutes with Blogsome
Theme designed by Jay of onefinejay.com