From bb63c4191f03aa8b7acdc8aa5a9269f84007d942 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 12 Oct 2014 11:29:02 -0700 Subject: 139 --- mu.arc.t | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/mu.arc.t b/mu.arc.t index 1f1329be..a4eab61a 100644 --- a/mu.arc.t +++ b/mu.arc.t @@ -641,13 +641,26 @@ (add-fns '((test1 ((1 type) <- copy (integer-address literal)) - ((2 integer-address) <- copy (34 literal)) + ((2 integer-address) <- copy (34 literal)) ; pointer to nowhere ((3 integer-address) (4 boolean) <- maybe-coerce (1 tagged-value) (integer-address literal))))) (run 'test1) ;? (prn memory*) (if (or (~is memory*.3 34) (~is memory*.4 t)) (prn "F - 'maybe-coerce' copies value only if type tag matches")) +(reset) +(new-trace "tagged-value-2") +;? (set dump-trace*) +(add-fns + '((test1 + ((1 type) <- copy (integer-address literal)) + ((2 integer-address) <- copy (34 literal)) ; pointer to nowhere + ((3 integer-address) (4 boolean) <- maybe-coerce (1 tagged-value) (boolean-address literal))))) +(run 'test1) +(prn memory*) +(if (or (~is memory*.3 0) (~is memory*.4 nil)) + (prn "F - 'maybe-coerce' doesn't copy value when type tag doesn't match")) + ; Just like the table of types is centralized, functions are conceptualized as ; a centralized table of operations just like the 'primitives' we've seen so ; far. If you create a function you can call it like any other op. -- cgit 1.4.1-2-gfad0