git.fiddlerwoaroof.com
Browse code

feat: add compiler macro for functionalize

Edward Langley authored on 26/03/2023 18:06:40
Showing 1 changed files
... ...
@@ -24,6 +24,16 @@
24 24
   (:method ((it function))
25 25
     it))
26 26
 
27
+(define-compiler-macro functionalize (&whole whole it)
28
+  (typecase it
29
+    (cons (destructuring-bind (h . tail) it
30
+            (declare (ignore tail))
31
+            (case h
32
+              (quote it)
33
+              (function it)
34
+              (t whole))))
35
+    (t whole)))
36
+
27 37
 ;;; TODO: consider making this wrap defalias?
28 38
 (defmacro shortcut (name function &body bound-args)
29 39
   `(eval-when (:load-toplevel :compile-toplevel :execute)