about summary refs log tree commit diff stats
path: root/045closure_name.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-03-08 01:30:14 -0800
committerKartik K. Agaram <vc@akkartik.com>2016-03-08 01:46:47 -0800
commit1ead356219bb2eb59487d1012f837bd07ec336f5 (patch)
treeaf15f390b81e4d6b3e0940c5756a0d7fd1060bb5 /045closure_name.cc
parent27ba0937a3747684f299bb7a8b3cdd0fbb689db3 (diff)
downloadmu-1ead356219bb2eb59487d1012f837bd07ec336f5.tar.gz
2735 - define recipes using 'def'
I'm dropping all mention of 'recipe' terminology from the Readme. That
way I hope to avoid further bike-shedding discussions while I very
slowly decide on the right terminology with my students.

I could be smarter in my error messages and use 'recipe' when code uses
it and 'function' otherwise. But what about other words like ingredient?
It would all add complexity that I'm not yet sure is worthwhile. But I
do want separate experiences for veteran programmers reading about Mu on
github and for people learning programming using Mu.
Diffstat (limited to '045closure_name.cc')
-rw-r--r--045closure_name.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/045closure_name.cc b/045closure_name.cc
index 368377fd..33ab8c07 100644
--- a/045closure_name.cc
+++ b/045closure_name.cc
@@ -4,26 +4,26 @@
 //: surrounding space of the surrounding space, etc.
 
 :(scenario closure)
-recipe main [
+def main [
   default-space:address:shared:array:location <- new location:type, 30
   1:address:shared:array:location/names:new-counter <- new-counter
   2:number/raw <- increment-counter 1:address:shared:array:location/names:new-counter
   3:number/raw <- increment-counter 1:address:shared:array:location/names:new-counter
 ]
 
-recipe new-counter [
+def new-counter [
   default-space:address:shared:array:location <- new location:type, 30
   x:number <- copy 23
   y:number <- copy 3  # variable that will be incremented
-  reply default-space:address:shared:array:location
+  return default-space:address:shared:array:location
 ]
 
-recipe increment-counter [
+def increment-counter [
   default-space:address:shared:array:location <- new location:type, 30
   0:address:shared:array:location/names:new-counter <- next-ingredient  # outer space must be created by 'new-counter' above
   y:number/space:1 <- add y:number/space:1, 1  # increment
   y:number <- copy 234  # dummy
-  reply y:number/space:1
+  return y:number/space:1
 ]
 
 +name: lexically surrounding space for recipe increment-counter comes from new-counter
@@ -152,7 +152,7 @@ bool already_transformed(const reagent& r, const map<string, long long int>& nam
 
 :(scenario missing_surrounding_space)
 % Hide_errors = true;
-recipe f [
+def f [
   local-scope
   x:number/space:1 <- copy 34
 ]