UnrealScript has always impressed me, somewhat, with it its intrinsic support for states (and latent functions) by grouping/overloading functions and fields into blocks like:
state() SomeState
{
...
function void Foo()
{
GotoState('SomeOtherState');
}
...
}
Which is quite a bit cleaner than using loads of switch-statements inside every function (it's almost some sort of design by contract).
Are there any other more general-purpose programming languages that intrinsically support state declarations similar to this (ignoring visual programming languages or tools like Workflow Foundation)?
Edit:
Some of the beauty of states in UnrealScript is that you can override stateful functions in subclasses, and even define new, named states. I think this is troublesome to do with enum-switches (where enums cannot be extended), delegates, or co-classes implementing different states, especially in languages like C# or Java that only support single-inheritance.