okamsn / loopy

A better looping and iteration macro for Emacs.
GNU General Public License v3.0
23 stars 3 forks source link

Create non-default way to bind variables in optional sub-sequences to nil #198

Open okamsn opened 3 months ago

okamsn commented 3 months ago

We want a way to bind the variables in optional subsequences to nil while still matching. For example, an optional vector won't match the fallback value nil for &optional.

Something like the below

;; => (1 2 nil nil)
(pcase (list 1 2)
  ((loopy (a b &optional ([c d] loopy-nil)))
   (list a b c d)))
;; => (1 2 nil nil)
(pcase (list 1 2)
  ;; Look like a function call?:
  ((loopy (a b &optional ([c d] (loopy-nil))))
   (list a b c d)))