3 ms·
According to Alan Kay true OO is message based. First you'd identify what the objects are -- it seems dog and cat. Then you have a choice. Can either send them
by rdtsc 11y ago
According to Alan Kay true OO is message based. First you'd identify what the objects are -- it seems dog and cat. Then you have a choice. Can either send them messages which look like {bark, softly}, {bark, loudly}, {run, fast}, {run, slow}. Similar for cat.
Or can think of dog having an internal state machine and can be in two states -- barking or running. When it is barking he can get two messages {softly} or {loudly}. If it is running, can get fast or slow messages. There is a way to switch from one state to another say getting a {bark} or {run}. Other messages might lead to an error/exception.
This way the first way of doing things is just sending a message which both switches state and regulates intensity of activity.
Heck pretty much a similar example is presented in Learn You Some Erlang For Great Good book in the "Rage Against the Finite State Machine":
http://learnyousomeerlang.com/finite-state-machines http://learnyousomeerlang.com/finite-state-machines
(My favorite state machine is a that of a cat though in that text)
- javajosh 11y agoYes indeed. But what I'm saying is that there is actually just one nameless state machine whose coordinate system is organized as a tree who's leaves represent the machine's degrees-of-freedom. It's kind of an odd thing: the leaf both partitions state, and it also co-locates the DoF for changing the state (or at least it's apparent state, if you're immutable). Neat link, I'll have to check it out. I've not done erlang but I'm quite intrigued by gen_server in particular. Sorry for talking about coordinate-systems: I can't help it, I have a physics degree.