From 34bb3fea8af9a9cfc0b728020cf9dd74a5b3e0e3 Mon Sep 17 00:00:00 2001 From: Pekka Laiho Date: Mon, 4 Jul 2022 15:55:38 +0700 Subject: [PATCH] ability to give custom env into readEval function --- src/Lisp.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Lisp.php b/src/Lisp.php index 8154ce9..7ae7fd7 100644 --- a/src/Lisp.php +++ b/src/Lisp.php @@ -39,13 +39,13 @@ class Lisp return $this->printer->pstr($value, $printReadable); } - public function readEval(string $input) + public function readEval(string $input, ?Env $customEnv = null) { $tokens = $this->tokenizer->tokenize($input); $expr = $this->reader->read($tokens); - return $this->eval->eval($expr, $this->env); + return $this->eval->eval($expr, $customEnv ? $customEnv : $this->env); } // read, eval, print