We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2c4012a commit eca7f7dCopy full SHA for eca7f7d
1 file changed
pixie/stdlib.pxi
@@ -2311,6 +2311,24 @@ Expands to calls to `extend-type`."
2311
([f col]
2312
(transduce (map f) conj col)))
2313
2314
+(defn macroexpand-1 [form]
2315
+ {:doc "If form is a macro call, returns the expanded form.
2316
+
2317
+ Does nothing if not a macro call."
2318
+ :signatures [[form]]
2319
+ :examples [["(macroexpand-1 '(when condition this and-this))"
2320
+ nil `(if condition (do this and-this))]
2321
+ ["(macroexpand-1 ())" nil ()]
2322
+ ["(macroexpand-1 [1 2])" nil [1 2]]]}
2323
+ (if (or (not (list? form))
2324
+ (= () form))
2325
+ form
2326
+ (let [[sym & args] form
2327
+ fvar (resolve sym)]
2328
+ (if (and fvar (macro? @fvar))
2329
+ (apply @fvar args)
2330
+ form))))
2331
2332
(def *1)
2333
(def *2)
2334
(def *3)
0 commit comments