logoGarden Of Blog


Unless

Posted in geek out by Marcus Del Greco on April 22nd, 2006

There is a command keyword in the Perl computer language called “unless.” It is used for conditional tests, when you’d like forego performing a set of actions unless a certain condition is met.

Some programmers consider using “unless” to be poor practice, because it flips conditional tests into a double-negative kind of thought process. The very same tests can be accomplished with the usual “if/else” constructs familiar to developers of almost any language.

But I like using “unless.” My brain seems to operate in this double-negative mode almost all the time. For instance:


unless ($salary eq "adequate") {
   lookForNewJob();
}
else {
   stayAndThrive();
}

or


unless ($all eq "well") {
   runAway();
}

It is a way of preparing for eventualities.

Still, there is a tension in needing to do such a thing. Wouldn’t it be nice to simply write…


stayAndThrive();

…with no conditions, because you know what you need to do, unconditionally? The stayAndThrive() routine is guaranteed to run, because there is no “unless,” there is no “if/else,” there is one true path to follow.

For this, no “unless…”

Snakes On A Plane

Posted in shameless plugs by Marcus Del Greco on April 20th, 2006

What a sensation. I haven’t wanted to see a film on opening night in a long time.

Snakes On A Plane.

I love it.