# Xkcd 09-09-19

**URL:** <https://boards.straightdope.com/t/xkcd-09-09-19/840036>\
**Category:** Cafe Society\
**Created:** [September 11, 2019, 12:41pm UTC](https://boards.straightdope.com/t/xkcd-09-09-19/840036 "2019-09-11T12:41:51Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lumpy](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lumpy/32/446_2.png) [@Lumpy](https://boards.straightdope.com/u/Lumpy)\
**Post date:** [September 11, 2019, 12:41pm UTC](https://boards.straightdope.com/t/xkcd-09-09-19/840036/1 "2019-09-11T12:41:51Z")

</div>

> **[Unreachable State](https://xkcd.com/2200/)**
>
> ERROR: We've reached an unreachable state. Anything is possible. The limits were in our heads all along. Follow your dreams.

Is this actually possible? How do you code for “what I thought was an unreachable state”?

---

<div class="post-metadata">

**Author:** ![Bryan\_Ekers](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/bryan_ekers/32/183_2.png) [@Bryan\_Ekers](https://boards.straightdope.com/u/Bryan_Ekers)\
**Post date:** [September 11, 2019, 1:16pm UTC](https://boards.straightdope.com/t/xkcd-09-09-19/840036/2 "2019-09-11T13:16:56Z")

</div>

I gather it could be a case of exception handling:

> [@](#):
>
> #include \<iostream\>  
> using namespace std;
> 
> int main()  
> {  
> int x = -1;
> 
> // Some code  
> cout \<\< "Before try  
> ";  
> try {  
> cout \<\< "Inside try  
> ";  
> if (x \< 0)  
> {  
> throw x;  
> cout \<\< "After throw (Never executed)  
> ";  
> }  
> }  
> catch (int x ) {  
> cout \<\< "Exception Caught  
> ";  
> }
> 
> cout \<\< "After catch (Will be executed)  
> ";  
> return 0;  
> }

The gist of this snippet is that _x_ has an integer value where only certain ranges are acceptable. If _x_ is unacceptably negative [i.e. \*if (x &lt; 0)\*], the program will “throw an exception” and run special code (in the “catch” portion) to handle the unusual case, ideally before passing a negative _x_ to another routine which will then crash, i.e. before passing _x_ to a routine that will calculate the square root of _x_.

I gather the programmer in the cartoon imagined some weird, wildly improbable value for _x_ (or whatever the variable in question is) and wrote a message saying in effect “I wrote this message just in case this wildly improbable circumstance occurred, but I’m too tired right now to think up a good way to handle the situation.”

---

<div class="post-metadata">

**Author:** ![Andy\_L](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@Andy\_L](https://boards.straightdope.com/u/Andy_L)\
**Post date:** [September 11, 2019, 1:26pm UTC](https://boards.straightdope.com/t/xkcd-09-09-19/840036/3 "2019-09-11T13:26:25Z")

</div>

> [@Bryan\_Ekers](#):
>
> I gather it could be a case of exception handling:  
> The gist of this snippet is that _x_ has an integer value where only certain ranges are acceptable. If _x_ is unacceptably negative [i.e. \*if (x &lt; 0)\*], the program will “throw an exception” and run special code (in the “catch” portion) to handle the unusual case, ideally before passing a negative _x_ to another routine which will then crash, i.e. before passing _x_ to a routine that will calculate the square root of _x_.
> 
> I gather the programmer in the cartoon imagined some weird, wildly improbable value for _x_ (or whatever the variable in question is) and wrote a message saying in effect “I wrote this message just in case this wildly improbable circumstance occurred, but I’m too tired right now to think up a good way to handle the situation.”

I think it’s more like he’s written code such that some condition ought never happen - like

If x\>0 then  
Do this;  
Else if x\<=0  
Do that;  
Else;  
Panic!  
End

If coded correctly there’s no way to get to the “Panic!” (x is either greater than zero or less than or equal to zero) - but an error in the code (like a way that x could change between the first two “ifs”) might make it possible to get to that point - and the poor programmer, recognizing if the system gets to “Panic,” it means that he made a subtle error that he’s incapable of figuring out, is writing a response that acknowledges that he’s the wrong person to be providing advice about what to do.

---

<div class="post-metadata">

**Author:** ![Bryan\_Ekers](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/bryan_ekers/32/183_2.png) [@Bryan\_Ekers](https://boards.straightdope.com/u/Bryan_Ekers)\
**Post date:** [September 11, 2019, 1:32pm UTC](https://boards.straightdope.com/t/xkcd-09-09-19/840036/4 "2019-09-11T13:32:43Z")

</div>

Yes… but exception handling is a more formal approach than writing a bunch of if/then/else lines.

---

<div class="post-metadata">

**Author:** ![Andy\_L](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@Andy\_L](https://boards.straightdope.com/u/Andy_L)\
**Post date:** [September 11, 2019, 1:39pm UTC](https://boards.straightdope.com/t/xkcd-09-09-19/840036/5 "2019-09-11T13:39:13Z")

</div>

> [@Bryan\_Ekers](#):
>
> Yes… but exception handling is a more formal approach than writing a bunch of if/then/else lines.

Absolutely - I was using the if/then/else just to provide a simple informal example.

---

<div class="post-metadata">

**Author:** ![Frodo](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/frodo/32/302_2.png) [@Frodo](https://boards.straightdope.com/u/Frodo)\
**Post date:** [September 11, 2019, 4:12pm UTC](https://boards.straightdope.com/t/xkcd-09-09-19/840036/6 "2019-09-11T16:12:08Z")

</div>

Typically used in the “default” option of switches:

switch (value)  
{  
case 1:  
DoThings()  
break;  
case 2:  
DoOtherThings()  
break;  
default:  
//Shouldn’t happen.  
break;  
}

---

<div class="post-metadata">

**Author:** ![ftg](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/ftg/32/2801_2.png) [@ftg](https://boards.straightdope.com/u/ftg)\
**Post date:** [September 11, 2019, 6:03pm UTC](https://boards.straightdope.com/t/xkcd-09-09-19/840036/7 "2019-09-11T18:03:28Z")

</div>

Writing your own code and getting it mostly right is _really_ hard. When other people are involved, and esp. as the software evolves over time, stuff starts getting Byzantine. So you’re responsible for a library that’s intended to be used in one context. Needs change so someone has the bright idea to use it another context. Being a little prescient you put in such an error message in your original code to handle stuff that shouldn’t happen. E.g., the hard drive your code is managing isn’t there anymore. When you wrote the code, USB drives didn’t exist.

Since you can’t program in all the weird things that might happen someday in the future when other stuff changes, you put in a default “Something really bad happened.” error message.

In short: It is impossible to predict what may wrong in the way the code is used in the future.

(Just checked. The XKCD forums were taken offline due to a hack on the 2nd. And they’re still down. There were so little used I now think that it might be permanent.)

---

<div class="post-metadata">

**Author:** ![AHunter3](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/ahunter3/32/368_2.png) [@AHunter3](https://boards.straightdope.com/u/AHunter3)\
**Post date:** [September 11, 2019, 6:18pm UTC](https://boards.straightdope.com/t/xkcd-09-09-19/840036/8 "2019-09-11T18:18:52Z")

</div>

I have often been in scripting situations where it seemed to me that things were as basic as this:

> [@Andy\_L](#):
>
> If x\>0 then  
> Do this;  
> Else if x\<=0  
> Do that;  
> Else;  
> Panic!  
> End

… but where, yes indeedy, there was something I had not taken into account.

TL;DR’ish example for anyone who wishes an example:  
I had a field on the database layout that was defined in such a way that it would never be empty – not only did it have an autofill startoff value, but validation requirements explicitly stated that field should not be empty and should be unique.

Under rarified circumstances – importing from a different system that might have overlapping values from the source, until they were properly modified by my import routine script – this field might contain numerical values that were not whole numbers (integers) but instead had a decimal point and an imposed tenth so as to shift them to a guaranteed-unique position. (My script would then fetch the lowest not-yet-in-use integer and apply it to the imported record and its child recs, thus getting rid of the temporary decimal).

Well, a numerical value either IS a freaking integer or it has a modulo (“remainder”) if divided by 1, right?

The thing I hadn’t counted on: FileMaker has a mode called “Find Mode” in which one is not situated on data, but instead is situated on a REQUEST which starts off with all fields empty (and the user populates the fields to specify what they wish to find).

The other thing I hadn’t counted on: A previous part of the import routine did not have the user’s ability to abort or pause operations to be disabled, and one of them hit the freaking escape key, god knows why, and then, with everything paused, chose to enter Find Mode.

The bloody field is blank in Find Mode (unless the user types in a number or numerical range expression). A blank field is neither an integer nor does it have a modulo.

“Hey **AHunter3** , I got a message onscreen that says ‘Nobody’s ever supposed to see this’, what did I do?”

/ TL;DR

---

<div class="post-metadata">

**Author:** ![Andy\_L](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@Andy\_L](https://boards.straightdope.com/u/Andy_L)\
**Post date:** [September 11, 2019, 6:31pm UTC](https://boards.straightdope.com/t/xkcd-09-09-19/840036/9 "2019-09-11T18:31:49Z")

</div>

> [@AHunter3](#):
>
> “Hey **AHunter3** , I got a message onscreen that says ‘Nobody’s ever supposed to see this’, what did I do?”
> 
> / TL;DR

Thanks.

---

<div class="post-metadata">

**Author:** ![Ponderoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/ponderoid/32/19221_2.png) [@Ponderoid](https://boards.straightdope.com/u/Ponderoid)\
**Post date:** [September 11, 2019, 8:16pm UTC](https://boards.straightdope.com/t/xkcd-09-09-19/840036/10 "2019-09-11T20:16:41Z")

</div>

“Never test for an error condition you don’t know how to handle.” --Apocryphal law of computer programming attributed to various authors.

---

<div class="post-metadata">

**Author:** ![Zyada](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/zyada/32/3028_2.png) [@Zyada](https://boards.straightdope.com/u/Zyada)\
**Post date:** [September 11, 2019, 8:48pm UTC](https://boards.straightdope.com/t/xkcd-09-09-19/840036/11 "2019-09-11T20:48:15Z")

</div>

There is a story I heard when working for Radio Shack. The version I’ve heard was supposed to have occurred at Radio Shack. (I have seen a similar version, only set in an Oil & Gas Co, but the page below makes me think the Radio Shack version is more likely)

A developer was working on the software for a Xenix system (Tandy’s flavor of unix) and ran into a potential hardware problem that should never happen. So he put the test in for it, and made the error “Shut her down, Scotty, she’s sucking mud”

In the story I heard, it did happen, and in the office of one of the upper muckety-mucks. Fortunately, the programmer had gone on to greener pa$ture$ by that time.  
[This page](http://www.trs-80.com/trs80-zaps-eastereggs.htm) doesn’t have the follow-up, but credits the programmer who put the error message in.

---

<div class="post-metadata">

**Author:** ![Pleonast](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/pleonast/32/1183_2.png) [@Pleonast](https://boards.straightdope.com/u/Pleonast)\
**Post date:** [September 11, 2019, 9:47pm UTC](https://boards.straightdope.com/t/xkcd-09-09-19/840036/12 "2019-09-11T21:47:15Z")

</div>

> [@Andy\_L](#):
>
> I think it’s more like he’s written code such that some condition ought never happen - like
> 
> If x\>0 then  
> Do this;  
> Else if x\<=0  
> Do that;  
> Else;  
> Panic!  
> End
> 
> If coded correctly there’s no way to get to the “Panic!” (x is either greater than zero or less than or equal to zero) - but an error in the code (like a way that x could change between the first two “ifs”) might make it possible to get to that point - and the poor programmer, recognizing if the system gets to “Panic,” it means that he made a subtle error that he’s incapable of figuring out, is writing a response that acknowledges that he’s the wrong person to be providing advice about what to do.

Floating-point variables can have the value [NaN](https://en.wikipedia.org/wiki/NaN), which has some odd properties. Most famous is that a NaN is not equal to itself (that is, nan==nan is false). It would also fail both comparisons in this code snippet and hit the panic mode.

---

<div class="post-metadata">

**Author:** ![Andy\_L](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@Andy\_L](https://boards.straightdope.com/u/Andy_L)\
**Post date:** [September 11, 2019, 9:50pm UTC](https://boards.straightdope.com/t/xkcd-09-09-19/840036/13 "2019-09-11T21:50:34Z")

</div>

> [@Pleonast](#):
>
> Floating-point variables can have the value [NaN](https://en.wikipedia.org/wiki/NaN), which has some odd properties. Most famous is that a NaN is not equal to itself (that is, nan==nan is false). It would also fail both comparisons in this code snippet and hit the panic mode.

Another good example.

The point of the comic’s joke is that the coder in the comic is tired and depressed enough that as he’s writing the display for supposedly impossible conditions, he has to acknowledge that the person makes the mistake allowing the impossible condition to occur is not the best person to advise what to do in those circumstances.

---

<div class="post-metadata">

**Author:** ![beowulff](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/beowulff/32/542_2.png) [@beowulff](https://boards.straightdope.com/u/beowulff)\
**Post date:** [September 11, 2019, 10:40pm UTC](https://boards.straightdope.com/t/xkcd-09-09-19/840036/14 "2019-09-11T22:40:50Z")

</div>

I suppose the error message “[Hodie Natus Est Radici Frater](https://multicians.org/hodie-natus-est.html)” is apropos here.

---

<div class="post-metadata">

**Author:** ![iamthewalrus\_3](https://avatars.discourse-cdn.com/v4/letter/i/258eb7/32.png) [@iamthewalrus\_3](https://boards.straightdope.com/u/iamthewalrus_3)\
**Post date:** [September 11, 2019, 11:31pm UTC](https://boards.straightdope.com/t/xkcd-09-09-19/840036/15 "2019-09-11T23:31:15Z")

</div>

I’ve definitely written an error message of that sort before. In my case it’s usually because I’m coding something to a technical spec that is at least a little bit ambiguous (as they all are), and I have to make some assumptions about how to resolve that ambiguity in code.

At some point I’ll likely have a few “I don’t know how this happened, but some invariant I thought was true really wasn’t” sorts of states. At some point, you just want a unique error so that when someone says “Hey, I saw an error that said this dumb thing”, you can search for that dumb thing in the code and see where it got to.

---

<div class="post-metadata">

**Author:** ![dzeiger](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@dzeiger](https://boards.straightdope.com/u/dzeiger)\
**Post date:** [September 12, 2019, 12:06am UTC](https://boards.straightdope.com/t/xkcd-09-09-19/840036/16 "2019-09-12T00:06:01Z")

</div>

> [@Zyada](#):
>
> [This page](http://www.trs-80.com/trs80-zaps-eastereggs.htm) doesn’t have the follow-up, but credits the programmer who put the error message in.

Small world, I worked with Frank when we were both at a dialup ISP in the 90s (Internet America, the 1-800-BE-A-GEEK people for anyone who was in the Dallas area at the time).

I recall him telling stories of his time at Tandy, but I don’t recall anything about this specific one.

---

<div class="post-metadata">

**Author:** ![Bryan\_Ekers](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/bryan_ekers/32/183_2.png) [@Bryan\_Ekers](https://boards.straightdope.com/u/Bryan_Ekers)\
**Post date:** [September 12, 2019, 1:20am UTC](https://boards.straightdope.com/t/xkcd-09-09-19/840036/17 "2019-09-12T01:20:53Z")

</div>

Related:

> [@](#):
>
> “5 a.m.: I’ve been at this all night, and I still can’t find the problem. I’m disgusted and I’m going to bed!”

-handwritten note in one of John von Neumann’s lab books. I hear ya, brother!

---

<div class="post-metadata">

**Author:** ![Small\_Clanger](https://avatars.discourse-cdn.com/v4/letter/s/9fc348/32.png) [@Small\_Clanger](https://boards.straightdope.com/u/Small_Clanger)\
**Post date:** [September 12, 2019, 5:49pm UTC](https://boards.straightdope.com/t/xkcd-09-09-19/840036/18 "2019-09-12T17:49:00Z")

</div>

Oracle PL/SQL has exception handling. There are _many_ built in exceptions, and you can define new ones. One of the built-ins is “WHEN OTHERS…” caught when everything else has slipped through.

You could put:

```auto

WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('Oh dear something unexpected happend') 

```

(and append an actual error code)  
The most common solution is:

```auto

WHEN OTHERS THEN NULL

```

…nothing to see here folks. No clues. You’re you’re own your own here.

P.S. From **Code Complete** (paraphrased). (Even if you never expect them to occur) do not use “cute” error messages.

---

<div class="post-metadata">

**Author:** ![jharvey963](https://avatars.discourse-cdn.com/v4/letter/j/54ee81/32.png) [@jharvey963](https://boards.straightdope.com/u/jharvey963)\
**Post date:** [September 13, 2019, 8:43pm UTC](https://boards.straightdope.com/t/xkcd-09-09-19/840036/19 "2019-09-13T20:43:22Z")

</div>

Way back in pre-historic times, I coded in Lisp which had a function for just this type of situation. IIRC, the function was called “shouldnt”.

J.

---

<div class="post-metadata">

**Author:** ![KneadToKnow](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/kneadtoknow/32/3999_2.png) [@KneadToKnow](https://boards.straightdope.com/u/KneadToKnow)\
**Post date:** [September 13, 2019, 8:44pm UTC](https://boards.straightdope.com/t/xkcd-09-09-19/840036/20 "2019-09-13T20:44:38Z")

</div>

Am I correct in my recollection that this type of situation is the origin of the legend of the legendary “Halt and catch fire” instruction?

[Next page](https://boards.straightdope.com/t/xkcd-09-09-19/840036.md?page=2)
