Skip to content

Commit

Permalink
Rewrite the docstring of macroexpand-all
Browse files Browse the repository at this point in the history
  • Loading branch information
Kodiologist committed Dec 13, 2024
1 parent 86ed35a commit 13cb2f7
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions hyrule/macrotools.hy
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,21 @@
~~res)))

(defn macroexpand-all [model [module None] [macros None]]
"Recursively performs all possible macroexpansions in form, using the ``require`` context of ``module-name``.
`macroexpand-all` assumes the calling module's context if unspecified.
"
"As :hy:func:`hy.macroexpand`, but with recursive descent through the input model, attempting to expand all macro calls throughout the tree::
(defmacro m [] 5)
(print (hy.repr (hy.macroexpand '(m))))
; => '5
(print (hy.repr (hy.macroexpand '(do (m)))))
; => '(do (m))
(print (hy.repr (macroexpand-all '(do (m)))))
; => '(do 5)
``macroexpand-all`` even expands macros in unquoted portions of quasiquoted forms::
(print (hy.repr (macroexpand-all '(do `[4 (m) ~(m) 6]))))
; => '(do `[4 (m) ~5 6])"

(setv quote-level 0 module (or module (hy.compiler.calling-module)))

(defn expand [m]
Expand Down

0 comments on commit 13cb2f7

Please sign in to comment.