about summary refs log tree commit diff stats
path: root/channel.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-05-07 15:06:53 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-05-07 15:29:13 -0700
commit0487a30e7078861ed7de42bdb21b5c71fb9b54a1 (patch)
treef7ccc4040b510403da90477947c1cf07ea91b627 /channel.mu
parent94fa5c95ad9c8beead183bb7c4b88c7c2c7ca6ec (diff)
downloadmu-0487a30e7078861ed7de42bdb21b5c71fb9b54a1.tar.gz
1298 - better ingredient/product handling
All primitives now always write to all their products. If a product is
not used that's fine, but if an instruction seems to expect too many
products mu will complain.

In the process, many primitives can operate on more than two ingredients
where it seems intuitive. You can add or divide more than two numbers
together, copy or negate multiple corresponding locations, etc.

There's one remaining bit of ugliness. Some instructions like
get/get-address, index/index-address, wait-for-location, these can
unnecessarily load values from memory when they don't need to.

Useful vim commands:
  %s/ingredients\[\([^\]]*\)\]/ingredients.at(\1)/gc
  %s/products\[\([^\]]*\)\]/products.at(\1)/gc
  .,$s/\[\(.\)]/.at(\1)/gc
Diffstat (limited to 'channel.mu')
-rw-r--r--channel.mu8
1 files changed, 2 insertions, 6 deletions
diff --git a/channel.mu b/channel.mu
index c20fa804..a0c2b6dd 100644
--- a/channel.mu
+++ b/channel.mu
@@ -8,9 +8,7 @@ recipe producer [
     done?:boolean <- lesser-than n:integer, 5:literal
     break-unless done?:boolean
     # other threads might get between these prints
-    $print [produce: ]
-    $print n:integer
-    $print [
+    $print [produce: ], n:integer, [
 ]
     chan:address:channel <- write chan:address:channel, n:integer
     n:integer <- add n:integer, 1:literal
@@ -26,9 +24,7 @@ recipe consumer [
     # read an integer from the channel
     n:integer, chan:address:channel <- read chan:address:channel
     # other threads might get between these prints
-    $print [consume: ]
-    $print n:integer
-    $print [
+    $print [consume: ], n:integer, [
 ]
     loop
   }