Skip to content

Commit

Permalink
Simplify loopy-let*.
Browse files Browse the repository at this point in the history
  • Loading branch information
okamsn committed Jan 27, 2024
1 parent 02c3847 commit 4f37c77
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions loopy.el
Original file line number Diff line number Diff line change
Expand Up @@ -981,16 +981,17 @@ you wish to use `pcase' destructuring, you should use `pcase-let'
instead of this macro."
(declare (debug ((&rest [sexp form]) body))
(indent 1))
;; Do this instead of using `pcase-let*' so that we error appropriately
;; as expected.
(loopy (accum-opt all-found-vars all-exprs)
(list (var val) bindings)
(set (expr found-vars) (loopy--destructure-for-iteration-default var val))
(append all-found-vars found-vars)
(collect all-exprs expr)
(finally-return `(let ,(seq-uniq all-found-vars)
,@all-exprs
,@body))))
(let ((result (macroexp-progn body))
(errsym (gensym "loopy--value-capture")))
(pcase-dolist (`(,var ,val) (reverse bindings))
(setq result `(pcase ,val
((loopy ,var)
,result)
(,errsym
(signal 'loopy-bad-run-time-destructuring
(list '(loopy ,var)
,errsym))))))
result))

;;;###autoload
(defmacro loopy-ref (bindings &rest body)
Expand Down

0 comments on commit 4f37c77

Please sign in to comment.