From a0fce05399b3ee284b6c60a409fad74c23432ce8 Mon Sep 17 00:00:00 2001
From: Akshay <nerdy@peppe.rs>
Date: Tue, 23 Mar 2021 18:56:13 +0530
Subject: macro based primitive implementor

---
 src/lisp/primitives.rs | 10 ++++++++++
 1 file changed, 10 insertions(+)
 create mode 100644 src/lisp/primitives.rs

(limited to 'src/lisp')

diff --git a/src/lisp/primitives.rs b/src/lisp/primitives.rs
new file mode 100644
index 0000000..1c9fe8e
--- /dev/null
+++ b/src/lisp/primitives.rs
@@ -0,0 +1,10 @@
+#[macro_export]
+macro_rules! primitive {
+    ($env:expr, $arity:expr, $name:expr, $closure:expr) => {
+        let val = crate::lisp::expr::LispExpr::PrimitiveFunc(crate::lisp::expr::PrimitiveFunc {
+            arity: $arity,
+            closure: $closure,
+        });
+        let _ = $env.insert($name.to_string(), val);
+    };
+}
-- 
cgit v1.2.3