aboutsummaryrefslogtreecommitdiff
path: root/proof_of_concepts.c
diff options
context:
space:
mode:
authorGravatar Moon Flower <moon@coffin.ir> 2025-02-27 14:49:26 +0330
committerGravatar Moon Flower <moon@coffin.ir> 2025-02-27 14:49:26 +0330
commit98b554584d06d85f20e10905efb96e4dd5f7c820 (patch)
tree0dc9ca8737c4caddbd4163d83f179913fc9629b7 /proof_of_concepts.c
parentmain.m4 -> moonshine.m4 (diff)
Slight revamp + Algebraic data types
Diffstat (limited to 'proof_of_concepts.c')
-rw-r--r--proof_of_concepts.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/proof_of_concepts.c b/proof_of_concepts.c
new file mode 100644
index 0000000..7afc90b
--- /dev/null
+++ b/proof_of_concepts.c
@@ -0,0 +1,11 @@
+#include "moonshine.h"
+
+// Free variable when it goes out of scope
+
+void cleanup_free(var *input) { print("Deallocation logic goes here ", input); }
+
+#define auto_free __attribute__((cleanup(cleanup_free)))
+
+#define create(type, name, ...) \
+ auto_free var cat(name, _parent) = __VA_ARGS__; \
+ type name = cat(name, _parent);