PDA

View Full Version : State names?


omnivore
07-30-04, 10:45 AM
I understand the state machine idea, but I haven't found what I want to know about states.

I assume that the names of states have to be unique, ie two machines cannot have two states with the same name but different definitions. But can two machines share a common state? And if so, I assume that this means that a single copy of the state exists that both machines reference?

If I test the boolean value of a state, does it have to be appended to a machine?

RMDumse
07-31-04, 01:29 PM
Interesting...

I've never tried having one state in two different machines.

I'm sure however, it is not a good thing. The purpose of the "ON-MACHINE" statement is to assign which machine owns the state that will follow in the "APPEND-STATE" statement. So only one machine can own a particular state.

Best to make all names unique.

Since all the names are (should) be unique, when you query the status of a state with "<name> IS-STATE?" it will find which machine the state is appended too, and then if that machine's state pointer is equal to that state number. So, essentially yes, the state must be appended to a machine.