aboutsummaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorTuncer Ayaz <[email protected]>2013-03-07 11:41:28 +0100
committerTuncer Ayaz <[email protected]>2013-03-07 11:41:28 +0100
commit0792d2102908a1008b08c37e1015ba5e6cb88882 (patch)
tree9a53d8b5029819a37fb17c7af050d67a8907ace3 /system
parent9e4a37c95739a524db9f7b8f7f64fa3c25264879 (diff)
downloadotp-0792d2102908a1008b08c37e1015ba5e6cb88882.tar.gz
otp-0792d2102908a1008b08c37e1015ba5e6cb88882.tar.bz2
otp-0792d2102908a1008b08c37e1015ba5e6cb88882.zip
Fix gen_fsm example code
Diffstat (limited to 'system')
-rw-r--r--system/doc/design_principles/fsm.xml9
1 files changed, 5 insertions, 4 deletions
diff --git a/system/doc/design_principles/fsm.xml b/system/doc/design_principles/fsm.xml
index bd19b88e2d..7decbb48cd 100644
--- a/system/doc/design_principles/fsm.xml
+++ b/system/doc/design_principles/fsm.xml
@@ -75,7 +75,7 @@ StateName(Event, StateData) ->
-export([init/1, locked/2, open/2]).
start_link(Code) ->
- gen_fsm:start_link({local, code_lock}, code_lock, Code, []).
+ gen_fsm:start_link({local, code_lock}, code_lock, lists:reverse(Code, []).
button(Digit) ->
gen_fsm:send_event(code_lock, {button, Digit}).
@@ -106,7 +106,8 @@ open(timeout, State) ->
calling <c>code_lock:start_link(Code)</c>:</p>
<code type="none">
start_link(Code) ->
- gen_fsm:start_link({local, code_lock}, code_lock, Code, []).</code>
+ gen_fsm:start_link({local, code_lock}, code_lock, lists:reverse(Code), []).
+ </code>
<p><c>start_link</c> calls the function <c>gen_fsm:start_link/4</c>.
This function spawns and links to a new process, a gen_fsm.</p>
<list type="bulleted">
@@ -130,8 +131,8 @@ start_link(Code) ->
corresponding to one process contained in one module.</p>
</item>
<item>
- <p>The third argument, <c>Code</c>, is a term which is passed
- as-is to the callback function <c>init</c>. Here, <c>init</c>
+ <p>The third argument, <c>Code</c>, is a list of digits which is passed
+ reversed to the callback function <c>init</c>. Here, <c>init</c>
gets the correct code for the lock as indata.</p>
</item>
<item>