diff --git a/xml/chapter2/section1/subsection3.xml b/xml/chapter2/section1/subsection3.xml index 08531e2f3..420bccf79 100644 --- a/xml/chapter2/section1/subsection3.xml +++ b/xml/chapter2/section1/subsection3.xml @@ -292,12 +292,14 @@ function pair(x, y) { - return m => - m === 0 - ? x - : m === 1 - ? y - : error(m, "Argument not 0 or 1 in pair"); + function dispatch(m) { + return m === 0 + ? x + : m === 1 + ? y + : error(m, "Argument not 0 or 1 in pair:"); + } + return dispatch; } function head(z) { return z(0); diff --git a/xml/chapter2/section4/subsection3.xml b/xml/chapter2/section4/subsection3.xml index c0b1b679b..4642a90bd 100644 --- a/xml/chapter2/section4/subsection3.xml +++ b/xml/chapter2/section4/subsection3.xml @@ -1526,7 +1526,7 @@ function make_from_real_imag(x, y) { : op === "angle" ? math_atan(y, x) : error(op, - "Unknown op in make_from_real_imag"); + "Unknown op in make_from_real_imag:"); } return dispatch; } diff --git a/xml/chapter3/section1/subsection1.xml b/xml/chapter3/section1/subsection1.xml index 2b3c48210..d140925dc 100644 --- a/xml/chapter3/section1/subsection1.xml +++ b/xml/chapter3/section1/subsection1.xml @@ -892,13 +892,11 @@ function make_account(balance) { return balance; } function dispatch(m) { - if (m === "withdraw") { - return withdraw; - } else if (m === "deposit") { - return deposit; - } else { - return "Unknown request in make_account"; - } + return m === "withdraw" + ? withdraw + : m === "deposit" + ? deposit + : error(m, "Unknown request in make_account"); } return dispatch; } diff --git a/xml/chapter3/section3/subsection1.xml b/xml/chapter3/section3/subsection1.xml index 647c6d1f7..35cc4d2fd 100644 --- a/xml/chapter3/section3/subsection1.xml +++ b/xml/chapter3/section3/subsection1.xml @@ -1551,12 +1551,14 @@ function count_pairs(x) { function pair(x, y) { - return m => - m === "head" - ? x - : m === "tail" - ? y - : error(m, "Argument not 0 or 1 in pair"); + function dispatch(m) { + return m === "head" + ? x + : m === "tail" + ? y + : error(m, "Undefined operation in pair:"); + } + return dispatch; } function head(z) { return z("head"); diff --git a/xml/chapter3/section3/subsection2.xml b/xml/chapter3/section3/subsection2.xml index b5d0774a7..ee9b0995a 100644 --- a/xml/chapter3/section3/subsection2.xml +++ b/xml/chapter3/section3/subsection2.xml @@ -697,10 +697,10 @@ delete_queue(q1); function make_queue() { - function front_ptr(...) ... - function rear_ptr(...) ... + function front_ptr(...) {...} + function rear_ptr(...) {...} //definitions of internal functions - function dispatch(m) ... + function dispatch(m) {...} return dispatch; } diff --git a/xml/chapter3/section3/subsection3.xml b/xml/chapter3/section3/subsection3.xml index bf9b067ab..ad482f2a6 100644 --- a/xml/chapter3/section3/subsection3.xml +++ b/xml/chapter3/section3/subsection3.xml @@ -525,7 +525,7 @@ function make_table() { ? lookup : m === "insert" ? insert - : "undefined operation -- table"; + : error(m, "Unknown operation in table:"; } return dispatch; } diff --git a/xml/chapter3/section4/subsection2.xml b/xml/chapter3/section4/subsection2.xml index c572f5905..7eeb03bde 100755 --- a/xml/chapter3/section4/subsection2.xml +++ b/xml/chapter3/section4/subsection2.xml @@ -480,14 +480,17 @@ function make_account(balance) { return balance; } const protect = make_serializer(); - return m => m === "withdraw" - ? protect(withdraw) - : m === "deposit" - ? protect(deposit) - : m === "balance" + function dispatch(m) { + return m === "withdraw" + ? protect(withdraw) + : m === "deposit" + ? protect(deposit) + : m === "balance" ? balance : error(m, "Unknown request in make_account:"); + } + return dispatch; } @@ -625,14 +628,17 @@ function make_account(balance) { return balance; } const protect = make_serializer(); - return m => m === "withdraw" - ? protect(withdraw) - : m === "deposit" - ? protect(deposit) - : m === "balance" + function dispatch(m) { + return m === "withdraw" + ? protect(withdraw) + : m === "deposit" + ? protect(deposit) + : m === "balance" ? protect(_ => balance)(undefined) // serialized : error(m, "Unknown request in make_account:"); + } + return dispatch; } @@ -718,14 +724,17 @@ function make_account(balance) { const protect = make_serializer(); const protect_withdraw = protect(withdraw); const protect_deposit = protect(deposit); - return m => m === "withdraw" - ? protect_withdraw - : m === "deposit" - ? protect_deposit - : m === "balance" + function dispatch(m) { + return m === "withdraw" + ? protect_withdraw + : m === "deposit" + ? protect_deposit + : m === "balance" ? balance : error(m, "Unknown request in make_account:"); + } + return dispatch; }