about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2014-07-06 01:53:18 -0700
committerKartik K. Agaram <vc@akkartik.com>2014-07-06 01:54:09 -0700
commita1fe0ff3c70de1acc3a34d7afaacf362b4fbb7ca (patch)
tree9c4866ceb022a3e375ea97ea879979501d2f8f42
parentc72d831021051afe144907d6cb594d8d6e0281aa (diff)
downloadmu-a1fe0ff3c70de1acc3a34d7afaacf362b4fbb7ca.tar.gz
2 - compound functions
-rw-r--r--mu.arc8
-rw-r--r--mu.arc.t13
-rw-r--r--x.mu1
3 files changed, 18 insertions, 4 deletions
diff --git a/mu.arc b/mu.arc
index 6990d35c..204d0b74 100644
--- a/mu.arc
+++ b/mu.arc
@@ -19,9 +19,11 @@
         add
           (= memory*.oarg1
              (+ memory*.arg1 memory*.arg2))
-        ; else
-          (prn "aaa")  ; user-defined functions go here
-        ))))
+        ; else user-defined function
+          (run function*.op)
+        )))
+;?   (prn "return")
+  )
 
 (awhen cdr.argv
   (each file it
diff --git a/mu.arc.t b/mu.arc.t
index 85dd1cc5..be4075ec 100644
--- a/mu.arc.t
+++ b/mu.arc.t
@@ -8,3 +8,16 @@
 (run function*!test1)
 (if (~iso memory* (obj 1 1  2 3  3 4))
   (prn "F - load and add instructions work"))
+
+(clear)
+(add-fns
+  '((add-fn
+      (3 <- add 1 2))
+    (main
+      (1 <- loadi 1)
+      (2 <- loadi 3)
+      (_ <- add-fn))))
+(run function*!main)
+;? (prn memory*)
+(if (~iso memory* (obj 1 1  2 3  3 4))
+  (prn "F - compound functions work"))
diff --git a/x.mu b/x.mu
index 6fbfaec0..98a75608 100644
--- a/x.mu
+++ b/x.mu
@@ -2,5 +2,4 @@
   (1 <- loadi 1)
   (2 <- loadi 3)
   (3 <- add 1 2)
-  (x <- prn a)
 )