about summary refs log tree commit diff stats
path: root/static_dispatch.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-10-29 21:23:48 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-10-29 21:27:45 -0700
commit39017bac428f554b84a15f4d6d7fa2a07eb7b16c (patch)
tree6bc418b5dff0653cea17937acf5cf89477cd7d6e /static_dispatch.mu
parent9cfb86fac1b90c957e7568a2d5fa5f737cdf90e4 (diff)
downloadmu-39017bac428f554b84a15f4d6d7fa2a07eb7b16c.tar.gz
2323 - static dispatch!
Diffstat (limited to 'static_dispatch.mu')
-rw-r--r--static_dispatch.mu21
1 files changed, 21 insertions, 0 deletions
diff --git a/static_dispatch.mu b/static_dispatch.mu
new file mode 100644
index 00000000..00160a2a
--- /dev/null
+++ b/static_dispatch.mu
@@ -0,0 +1,21 @@
+recipe test a:number -> b:number [
+  local-scope
+  load-ingredients
+  b <- add a, 1
+]
+
+recipe test a:number, b:number -> c:number [
+  local-scope
+  load-ingredients
+  c <- add a, b
+]
+
+recipe main [
+  local-scope
+  a:number <- test 3  # selects single-ingredient version
+  $print a, 10/newline
+  b:number <- test 3, 4  # selects double-ingredient version
+  $print b, 10/newline
+  c:number <- test 3, 4, 5  # prefers double- to single-ingredient version
+  $print c, 10/newline
+]