about summary refs log tree commit diff stats
path: root/072channel.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-04-10 20:47:44 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-04-10 20:55:10 -0700
commit5f141f6a461bfaf23cb75603b18c09d65a8d79af (patch)
treee246faa3c58ef1a4db34b8739ad1bb249b62f230 /072channel.mu
parent5939c226b41d6876aa7a36833a01a241925ddd00 (diff)
downloadmu-5f141f6a461bfaf23cb75603b18c09d65a8d79af.tar.gz
2829 - issues while switching to 'put'
1. It turns out we couldn't overload 'get' and 'get-address' until now,
because transform_names looks for those names, and the
resolve_ambiguous_calls transform happens before transform_names. Why
does resolve_ambiguous_calls happen before transform_names? Because if
my students made mistakes in the ingredients to an instruction they got
overzealous errors from resolve_ambiguous_calls. Now this impacts 'put'
as well, which is already overloaded for tables. Not sure what to do
about this; I'm going to go back to the overzealous errors, and just
teach students to visually scan past them for now.

2. I need addresses in a third place besides storing to containers and
arrays, and managing the heap -- to synchronize routines.
wait-for-location requires an address. Not sure what to do about this..
Diffstat (limited to '072channel.mu')
-rw-r--r--072channel.mu19
1 files changed, 6 insertions, 13 deletions
diff --git a/072channel.mu b/072channel.mu
index f1a4480d..0e9b0041 100644
--- a/072channel.mu
+++ b/072channel.mu
@@ -46,22 +46,15 @@ def new-channel capacity:number -> in:address:shared:source:_elem, out:address:s
   local-scope
   load-ingredients
   result:address:shared:channel:_elem <- new {(channel _elem): type}
-  # result.first-full = 0
-  full:address:number <- get-address *result, first-full:offset
-  *full <- copy 0
-  # result.first-free = 0
-  free:address:number <- get-address *result, first-free:offset
-  *free <- copy 0
-  # result.data = new location[ingredient+1]
+  *result <- put *result, first-full:offset, 0
+  *result <- put *result, first-free:offset, 0
   capacity <- add capacity, 1  # unused slot for 'full?' below
-  dest:address:address:shared:array:_elem <- get-address *result, data:offset
-  *dest <- new _elem:type, capacity
+  data:address:shared:array:_elem <- new _elem:type, capacity
+  *result <- put *result, data:offset, data
   in <- new {(source _elem): type}
-  chan:address:address:shared:channel:_elem <- get-address *in, chan:offset
-  *chan <- copy result
+  *in <- put *in, chan:offset, result
   out <- new {(sink _elem): type}
-  chan:address:address:shared:channel:_elem <- get-address *out, chan:offset
-  *chan <- copy result
+  *out <- put *out, chan:offset, result
 ]
 
 def write out:address:shared:sink:_elem, val:_elem -> out:address:shared:sink:_elem [