Message to No One

Posted on February 22, 2022 by psu

Long time readers of this site will know that I have spent a non-trivial portion of my adult life writing Objective-C code for the NeXT^H^H^H^H MacOS and iOS platforms at various stages of their development.

One quirk in the Objective-C runtime that every programmer needs to deal with is the following strange behavior: if you call a method on an object that is nil the call just falls through like nothing happened (usually).

That is, if you make a call like this:

result = [someObject someMethod:someArgument]

and someObject is the value nil, so it points at nothing, the behavior of the Objective-C runtime is just to ignore the call like nothing happened and effectively return a value similar to zero or nil.

In the more modern versions of the runtime, the area that the runtime uses to write the result of the method call is zero’d out no matter what the type of the return value will be. In older versions of the runtime you could get into trouble because this “return 0” behavior only worked if the method returned something that was the size of a pointer, or integer, on the runtime platform. And on PowerPC if you called a method that returned a float or double you could get all kinds of undefined suffering.

Anyway, I was having a chat with a nerd friend of mine at work, and we both got curious if this behavior dated back to the original Objective-C runtime or if it was added at some point. With the entire Internet at our fingertips surely this could not be that hard to figure out.

So I poked around, and the earliest reference that I could find with straightforward searches was a reference to this behavior on USENET in 1994:

You can read that here.

I did manage to find a copy of the original Objective-C book on, but there is no mention of this behavior in that book.

I also found this historical article from the ACM last year but it also did not specifically talk about the nil-messaging behavior.

Then I realized I should search but I really wasn’t sure what to look for and the site was loading slowly. Disappointed, and feeling lazy, I decided to see what twitter thought:

This, it turned out, was the perfect thing to use the giant nerd village for.

Within a few minutes there was confirmation that the behavior certainly existed and was documented by 1995

Then later we got back to 1993

There was runtime nerding by runtime nerds.

There was also funny runtime snarking by the same runtime nerds. This tweet, by the way, is true. I have seen such code and will leave it at that.

Then, I got this message which won the day with a reference back to a post in the Squeak forums, of all things. So now we have the following facts:

  1. The long post verifies that the original Objective-C runtimes threw an error when told to send messages to nil, and that this was changed to the current fall-through behavior in a release of some software called “ICPack 201”. This package was released by a company called Stepstone, which originally developed and owned the language in the 80s.

  2. The only information about this company that I could find on the Internet was the wikipedia entry which mentions “ICPack 201” but does not say when it was released. But, it does say that the package was proposed to the Open Software Foundation when they did their Request for Technology for their window management system, the software that eventually became Motif (shudder).

  3. Now, the wikipedia entry for Motif says that the RTF for the OSF window manager happened in 1988, so this mean that “ICPack 201” must have shipped sometime around 1988. Hooray!

Finally, a few hours later I got this reference to more NeXT documentation from 1990. Of course this manual is on bitsavers, like I figured it would be.

While in the end I could have found it myself, the great nerd convergence around this question was kinda fun.

But, don’t let this apparently heartwarming story change your mind about twitter. It’s still a cesspool that should mostly be avoided.

But once in a while it’s not too bad.

Final Note

It turns out that I did find this stackoverflow thread in my first few searches, and it also has the reference to the Squeak post. But I missed it my first time through. So there you go. If I had had better eyes I would have missed out on a minor twitter storm.