From 9aa9d4b20fb95bbaed7204c73a55635cb5df0bac Mon Sep 17 00:00:00 2001 From: Pekka Laiho Date: Mon, 4 Jul 2022 13:28:16 +0700 Subject: [PATCH] add macros when and unless --- src/LispFactory.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/LispFactory.php b/src/LispFactory.php index f826f13..5969d25 100644 --- a/src/LispFactory.php +++ b/src/LispFactory.php @@ -55,6 +55,9 @@ class LispFactory $lisp->readEval('(def defn (macro (name args body) (quasiquote (def (unquote name) (fn (unquote args) (unquote body))))))'); $lisp->readEval('(def defmacro (macro (name args body) (quasiquote (def (unquote name) (macro (unquote args) (unquote body))))))'); + $lisp->readEval('(def when (macro (test body) (quasiquote (if (unquote test) (unquote body) null))))'); + $lisp->readEval('(def unless (macro (test body) (quasiquote (if (unquote test) null (unquote body)))))'); + // Separate environment for user-defined stuff $lisp->setEnv(new Env('user', $env));