reinux: Also, I'm guessing immutability is impossible when you need to abstract the state of a non-stateless network protocol.
Actually, you can model state without keeping a mutable variable. The State Pattern gets you part-way there: it suggests keeping state by instantiating singleton objects, and maintaining a mutable reference to the current state class.
In a functional language that supports mutually-recursive functions, though, you can keep the state in the instruction pointer by calling the correct function for the state you want to transition to; about as close as you can get to totally immutable in a von Neuuman Architecture.
For an example in F#, see the bubble sort code in this thread.
"It seems that perfection is reached, not when there is nothing left to add, but rather when nothing more can be taken away." -- Antoine de St. Exupéry