diff options
-rw-r--r-- | mu.arc | 14 | ||||
-rw-r--r-- | mu.arc.t | 21 |
2 files changed, 31 insertions, 4 deletions
diff --git a/mu.arc b/mu.arc index 7ac37993..87c84bb0 100644 --- a/mu.arc +++ b/mu.arc @@ -489,12 +489,18 @@ (if (len> caller-args.routine* idx) (list caller-args.routine*.idx t) (list nil nil))) + prepare-reply + (= results.routine* + (accum yield + (each a arg + (yield (m a))))) reply (do - (= results.routine* - (accum yield - (each a arg - (yield (m a))))) + (when arg + (= results.routine* + (accum yield + (each a arg + (yield (m a)))))) (let results results.routine* (pop-stack routine*) (if empty.routine* (return ninstrs)) diff --git a/mu.arc.t b/mu.arc.t index a38ddc37..6f26ec7d 100644 --- a/mu.arc.t +++ b/mu.arc.t @@ -1003,6 +1003,27 @@ 4 1 5 3 6 4)) (prn "F - 'reply' permits a function to return multiple values at once")) +(reset) +(new-trace "new-fn-prepare-reply") +(add-fns + '((test1 + ((4 integer) <- arg) + ((5 integer) <- arg) + ((6 integer) <- add (4 integer) (5 integer)) + (prepare-reply (6 integer) (5 integer)) + (reply) + ((4 integer) <- copy (34 literal))) + (main + ((1 integer) <- copy (1 literal)) + ((2 integer) <- copy (3 literal)) + ((3 integer) (7 integer) <- test1 (1 integer) (2 integer))))) +(run 'main) +;? (prn memory*) +(if (~iso memory* (obj 1 1 2 3 3 4 7 3 + ; add-fn's temporaries + 4 1 5 3 6 4)) + (prn "F - without args, 'reply' returns values from previous 'prepare-reply'.")) + ; Our control operators are quite inconvenient to use, so mu provides a ; lightweight tool called 'convert-braces' to work in a slightly more ; convenient format with nested braces: |