about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-04-27 15:37:09 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-04-27 15:37:09 -0700
commit5109e78fab2e94059763eefaec93bd6649d22c1f (patch)
treeadf53b2bff6745095e352d2fd147006998acb4ed
parente765f9e74abc81b738e8670c6d77d363894107b1 (diff)
downloadmu-5109e78fab2e94059763eefaec93bd6649d22c1f.tar.gz
2874
Be more consistent that 'return' is the name of the instruction, and
'reply' just a synonym. Maybe I should take it out. It wouldn't affect
the recipe/ingredient terminology while I teach..
-rw-r--r--028call_reply.cc22
-rw-r--r--030container.cc2
-rw-r--r--033address.cc2
-rw-r--r--040brace.cc40
-rw-r--r--055recipe_header.cc8
5 files changed, 37 insertions, 37 deletions
diff --git a/028call_reply.cc b/028call_reply.cc
index 09360d25..0f320aa0 100644
--- a/028call_reply.cc
+++ b/028call_reply.cc
@@ -1,6 +1,6 @@
 //: Calls can also generate products, using 'reply' or 'return'.
 
-:(scenario reply)
+:(scenario return)
 def main [
   1:number, 2:number <- f 34
 ]
@@ -13,16 +13,16 @@ def f [
 +mem: storing 35 in location 2
 
 :(before "End Primitive Recipe Declarations")
-REPLY,
+RETURN,
 :(before "End Primitive Recipe Numbers")
-put(Recipe_ordinal, "reply", REPLY);
-put(Recipe_ordinal, "return", REPLY);
+put(Recipe_ordinal, "return", RETURN);
+put(Recipe_ordinal, "reply", RETURN);  // synonym while teaching
 :(before "End Primitive Recipe Checks")
-case REPLY: {
+case RETURN: {
   break;  // checks will be performed by a transform below
 }
 :(before "End Primitive Recipe Implementations")
-case REPLY: {
+case RETURN: {
   // Starting Reply
   if (Trace_stream) {
     trace(9999, "trace") << "reply: decrementing callstack depth from " << Trace_stream->callstack_depth << end();
@@ -61,7 +61,7 @@ void check_types_of_reply_instructions(recipe_ordinal r) {
     const recipe& callee = get(Recipe, caller_instruction.operation);
     for (int i = 0; i < SIZE(callee.steps); ++i) {
       const instruction& reply_inst = callee.steps.at(i);
-      if (reply_inst.operation != REPLY) continue;
+      if (reply_inst.operation != RETURN) continue;
       // check types with the caller
       if (SIZE(caller_instruction.products) > SIZE(reply_inst.ingredients)) {
         raise << maybe(caller.name) << "too few values replied from " << callee.name << '\n' << end();
@@ -70,7 +70,7 @@ void check_types_of_reply_instructions(recipe_ordinal r) {
       for (int i = 0; i < SIZE(caller_instruction.products); ++i) {
         reagent lhs = reply_inst.ingredients.at(i);
         reagent rhs = caller_instruction.products.at(i);
-        // End Check REPLY Copy(lhs, rhs)
+        // End Check RETURN Copy(lhs, rhs)
         if (!types_coercible(rhs, lhs)) {
           raise << maybe(callee.name) << reply_inst.name << " ingredient " << lhs.original_string << " can't be saved in " << rhs.original_string << '\n' << end();
           raise << to_string(lhs.type) << " vs " << to_string(rhs.type) << '\n' << end();
@@ -101,7 +101,7 @@ void check_types_of_reply_instructions(recipe_ordinal r) {
   }
 }
 
-:(scenario reply_type_mismatch)
+:(scenario return_type_mismatch)
 % Hide_errors = true;
 def main [
   3:number <- f 2
@@ -119,7 +119,7 @@ def f [
 //: the recipe's 'reply' will help catch accidental misuse of such
 //: 'ingredient-products' (sometimes called in-out parameters in other languages).
 
-:(scenario reply_same_as_ingredient)
+:(scenario return_same_as_ingredient)
 % Hide_errors = true;
 def main [
   1:number <- copy 0
@@ -131,7 +131,7 @@ def test1 [
 ]
 +error: main: '2:number <- test1 1:number' should write to 1:number rather than 2:number
 
-:(scenario reply_same_as_ingredient_dummy)
+:(scenario return_same_as_ingredient_dummy)
 def main [
   1:number <- copy 0
   _ <- test1 1:number  # call with different ingredient and product
diff --git a/030container.cc b/030container.cc
index ead9be70..3398e9ec 100644
--- a/030container.cc
+++ b/030container.cc
@@ -52,7 +52,7 @@ def main [
 +mem: storing 36 in location 17
 
 //: products of recipes can include containers
-:(scenario reply_container)
+:(scenario return_container)
 def main [
   3:point <- f 2
 ]
diff --git a/033address.cc b/033address.cc
index 31405c86..2ea35a59 100644
--- a/033address.cc
+++ b/033address.cc
@@ -496,7 +496,7 @@ if (!canonize_type(product)) continue;
 canonize_type(ingredient);
 :(before "End Preprocess NEXT_INGREDIENT product")
 canonize_type(product);
-:(before "End Check REPLY Copy(lhs, rhs)
+:(before "End Check RETURN Copy(lhs, rhs)
 canonize_type(lhs);
 canonize_type(rhs);
 
diff --git a/040brace.cc b/040brace.cc
index 3c295df9..e9f83d5a 100644
--- a/040brace.cc
+++ b/040brace.cc
@@ -361,9 +361,9 @@ def main [
 ]
 +error: break-if expects 1 or 2 ingredients, but got none
 
-//: Using break we can now implement conditional reply.
+//: Using break we can now implement conditional returns.
 
-:(scenario reply_if)
+:(scenario return_if)
 def main [
   1:number <- test1
 ]
@@ -373,7 +373,7 @@ def test1 [
 ]
 +mem: storing 35 in location 1
 
-:(scenario reply_if_2)
+:(scenario return_if_2)
 def main [
   1:number <- test1
 ]
@@ -384,32 +384,32 @@ def test1 [
 +mem: storing 34 in location 1
 
 :(before "End Rewrite Instruction(curr, recipe result)")
-// rewrite `reply-if a, b, c, ...` to
+// rewrite `return-if a, b, c, ...` to
 //   ```
 //   {
 //     break-unless a
-//     reply b, c, ...
+//     return b, c, ...
 //   }
 //   ```
-if (curr.name == "reply-if" || curr.name == "return-if") {
+if (curr.name == "return-if" || curr.name == "reply-if") {
   if (curr.products.empty()) {
-    emit_reply_block(result, "break-unless", curr.ingredients);
+    emit_return_block(result, "break-unless", curr.ingredients);
     curr.clear();
   }
   else {
     raise << "'" << curr.name << "' never yields any products\n" << end();
   }
 }
-// rewrite `reply-unless a, b, c, ...` to
+// rewrite `return-unless a, b, c, ...` to
 //   ```
 //   {
 //     break-if a
-//     reply b, c, ...
+//     return b, c, ...
 //   }
 //   ```
-if (curr.name == "reply-unless" || curr.name == "return-unless") {
+if (curr.name == "return-unless" || curr.name == "reply-unless") {
   if (curr.products.empty()) {
-    emit_reply_block(result, "break-if", curr.ingredients);
+    emit_return_block(result, "break-if", curr.ingredients);
     curr.clear();
   }
   else {
@@ -418,10 +418,10 @@ if (curr.name == "reply-unless" || curr.name == "return-unless") {
 }
 
 :(code)
-void emit_reply_block(recipe& out, const string& break_command, const vector<reagent>& ingredients) {
+void emit_return_block(recipe& out, const string& break_command, const vector<reagent>& ingredients) {
   reagent condition = ingredients.at(0);
-  vector<reagent> reply_ingredients;
-  copy(++ingredients.begin(), ingredients.end(), inserter(reply_ingredients, reply_ingredients.end()));
+  vector<reagent> return_ingredients;
+  copy(++ingredients.begin(), ingredients.end(), inserter(return_ingredients, return_ingredients.end()));
 
   // {
   instruction open_label;  open_label.is_label=true;  open_label.label = "{";
@@ -434,12 +434,12 @@ void emit_reply_block(recipe& out, const string& break_command, const vector<rea
   break_inst.ingredients.push_back(condition);
   out.steps.push_back(break_inst);
 
-  // reply <reply ingredients>
-  instruction reply_inst;
-  reply_inst.operation = get(Recipe_ordinal, "reply");
-  reply_inst.name = "reply";
-  reply_inst.ingredients.swap(reply_ingredients);
-  out.steps.push_back(reply_inst);
+  // return <return ingredients>
+  instruction return_inst;
+  return_inst.operation = get(Recipe_ordinal, "return");
+  return_inst.name = "return";
+  return_inst.ingredients.swap(return_ingredients);
+  out.steps.push_back(return_inst);
 
   // }
   instruction close_label;  close_label.is_label=true;  close_label.label = "}";
diff --git a/055recipe_header.cc b/055recipe_header.cc
index 9a4ec089..229a514d 100644
--- a/055recipe_header.cc
+++ b/055recipe_header.cc
@@ -361,7 +361,7 @@ void deduce_types_from_header(const recipe_ordinal r) {
 //: One final convenience: no need to say what to return if the information is
 //: in the header.
 
-:(scenario reply_based_on_header)
+:(scenario return_based_on_header)
 def main [
   1:number/raw <- add2 3, 5
 ]
@@ -426,7 +426,7 @@ def add2 a:number, b:number -> y:number, z:number [
 +mem: storing 3 in location 1
 +mem: storing -2 in location 2
 
-:(scenario reply_on_fallthrough_based_on_header)
+:(scenario return_on_fallthrough_based_on_header)
 def main [
   1:number/raw <- add2 3, 5
 ]
@@ -438,7 +438,7 @@ def add2 x:number, y:number -> z:number [
 +transform: instruction: reply {z: "number"}
 +mem: storing 8 in location 1
 
-:(scenario reply_on_fallthrough_already_exists)
+:(scenario return_on_fallthrough_already_exists)
 def main [
   1:number/raw <- add2 3, 5
 ]
@@ -452,7 +452,7 @@ def add2 x:number, y:number -> z:number [
 -transform: instruction: reply z:number
 +mem: storing 8 in location 1
 
-:(scenario reply_after_conditional_reply_based_on_header)
+:(scenario return_after_conditional_reply_based_on_header)
 def main [
   1:number/raw <- add2 3, 5
 ]