When I open Terminal, I get an "I have no name!" prompt Suddenly, this morning, I open a Terminal window and I get this:

I have no name!@macbook:~$ whoami
502


** I am not a number!  I am a human being! **

What gives?  Anyone know what I need to do to get my name back?  

I suppose there are two problems here, one is that my hostname is undefined, the other is that whoami reports my name as a number.
Something in memory got corrupted, and the mapping between your userID (502) and your username (ipd) was lost.  I've seen it happen (usually when I've manually killed hung system processes), although I'm not sure exactly what causes it.  launchd maybe?

Because that mapping is lost, whoami can't convert your ID into a username so returns the ID, and your prompt defaults to the "I have no name!" message because you effectively don't have a name.

Logging out and back in might fixit, but restarting is the best way (as you discovered).

Basically, it's a symptom of another problem, and not a problem in and of itself.