Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Stuff that annoys you...

Name: Anonymous 2010-09-03 12:45

when reading code not written by yourself. For example, I cannot stand it when  people use

if (condition)
    ...
else if (condition)
    ...
else if (condition)
    ...
else if (condition)
    ...
else


instead of the much more readable


if (condition)
    ...
else
    if (condition)
        ...
    else
        if (condition)
            ...
        else
            if (condition)
                ...
            else

Name: Anonymous 2010-09-03 12:51

The first is more readable in your example.
Here's something to show that the first is even more annoying than the second in a language that has a macro for the first:

;;; 1
(cond
  (predicate1 executed-if-1)
  (predicate2 executed-if-2)
  (predicate3 executed-if-3)
  (t executed-if-all-else-fails))

;;; 2
(if predicate1
    (progn executed-if-1)
    (if predicate2
        (progn executed-if-2)
        (if predicate3
            (progn executed-if-3)
            (progn executed-if-all-else-fails))))

So far the only person who prefers IF to COND for nested IF's that I've heard of is Paul Graham, but not like his other preferences are very idiomatic.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List