From fabb722c8df6b4b049c13d84f83d9f07c2bed92d Mon Sep 17 00:00:00 2001 From: LouisJackman <11330428+LouisJackman@users.noreply.github.com> Date: Sat, 16 May 2020 15:15:57 +0100 Subject: [PATCH] Add a dbg macro for easy var dumping --- src/boot/boot.janet | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/boot/boot.janet b/src/boot/boot.janet index 325893fc..87ea307e 100644 --- a/src/boot/boot.janet +++ b/src/boot/boot.janet @@ -945,6 +945,22 @@ (array/push parts (tuple apply f $args))) (tuple 'fn (tuple '& $args) (tuple/slice parts 0))) +(defmacro dbg + "Displays the variables or literals listed, providing both the name and + and the value for variables. Designed for quick debugging of values and + nothing else." + [& forms] + ~(do + ,;(map (fn [arg] + (def preface (if (symbol? arg) + (string "`" arg "` has value ") + "Literal has value ")) + ~(do + (prin ,preface) + (pp ,arg) + nil)) + forms))) + (defmacro -> "Threading macro. Inserts x as the second value in the first form in forms, and inserts the modified first form into the second form