The Opposite of If

November 30, 2006

I can’t remember where I first saw it, but I once found a riddle that really caught my boyish imagination (that shows you how long ago it was): “What is the opposite of if?”

I wrestled for goodly time with that, and to be perfectly honest I can’t remember now whether I worked out the answer or had to look it up. Look away now if you want to think about it some more. Ok? The answer, of course, is “unless”.

It had never occurred to me that “if” had an opposite, and the more I thought about it the more wonderful it seemed. Then sometime later I was struggling to understand some bit of programming code that someone (possibly me) had written with lots of “if not (a) and not (b) then…” and I thought what a fantastic thing it would be if there was an “unless” statement in more programming languages.

I think Perl and some Logos have it now, but surely it should be made compulsory: any compiler writer implementing an “if” should have to offer the natural opposite “unless”. Result: better readability and maintainability, every programmer’s dream. I don’t know who would enforce this though. Perhaps the Queen would like to get involved?

Ooh, I see the Ruby language has it too. Perhaps Her Majesty has already begun to put the world to rights. God bless her!


One Response to “The Opposite of If”

  1. Stephen Says:

    I remember us discussing this very thing and I actually amused a few others over the years with the same question.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: