diff options
author | Akshay <[email protected]> | 2021-03-23 13:26:13 +0000 |
---|---|---|
committer | Akshay <[email protected]> | 2021-03-23 13:26:13 +0000 |
commit | a0fce05399b3ee284b6c60a409fad74c23432ce8 (patch) | |
tree | ca661845ee5c4bd60c702d00c6fb68c74ea1837f | |
parent | 005156915c9d1d36500b73b9c44d9179aecd8c2f (diff) |
macro based primitive implementor
-rw-r--r-- | src/lisp/primitives.rs | 10 |
1 files changed, 10 insertions, 0 deletions
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 @@ | |||
1 | #[macro_export] | ||
2 | macro_rules! primitive { | ||
3 | ($env:expr, $arity:expr, $name:expr, $closure:expr) => { | ||
4 | let val = crate::lisp::expr::LispExpr::PrimitiveFunc(crate::lisp::expr::PrimitiveFunc { | ||
5 | arity: $arity, | ||
6 | closure: $closure, | ||
7 | }); | ||
8 | let _ = $env.insert($name.to_string(), val); | ||
9 | }; | ||
10 | } | ||