From 9dd963e5b20cbd93fb934c28aa5b4efbd419bb9e Mon Sep 17 00:00:00 2001 From: Scott Richmond Date: Thu, 19 May 2022 18:12:55 -0400 Subject: [PATCH] Interpret panic! not as fn but as rw. --- src/ludus/interpreter.clj | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ludus/interpreter.clj b/src/ludus/interpreter.clj index 5677650..a51d73b 100644 --- a/src/ludus/interpreter.clj +++ b/src/ludus/interpreter.clj @@ -308,6 +308,9 @@ )) ) +(defn- panic [ast ctx] + (throw (ex-info (show/show (interpret-ast (:expr ast) ctx)) {:ast ast}))) + (defn interpret-ast [ast ctx] (case (::ast/type ast) @@ -337,6 +340,8 @@ ::ast/ref (interpret-ref ast ctx) + ::ast/panic (panic ast ctx) + ::ast/recur {::data/recur true :tuple (interpret-ast (:tuple ast) ctx)} @@ -406,8 +411,10 @@ (def source " - let :foo = :bar + print (:foo) + print (:bar) + panic! \"well, shit\" ")