refactor!(lib): rename fn!->lambda! & fn!!->fn!

BREAKING CHANGE: This renames the fn! macro to lambda! and fn!! to fn!.
I hadn't put much thought into their names when they were added, but now
that they're seeing more use, I've reconsidered.

The reasoning is (and I'll refer to them by their new names):

- If you're using fn!, you care more about the syntax's brevity, than if
  you were using lambda!, so I wanted fn! to have the (even if slightly)
  shorter name.
- lambda! decorates native lambda (with cl-function). Its old name
  did not suggest that connection like other !-macros in Doom's library
  do.
- Their old names implied the two macros were somehow related or that
  one decorated the other. They aren't and don't.
This commit is contained in:
Henrik Lissner 2022-06-21 20:56:02 +02:00
parent ca73a689ab
commit 23feb482e9
No known key found for this signature in database
GPG key ID: B60957CA074D39A3
6 changed files with 30 additions and 30 deletions

View file

@ -251,7 +251,7 @@ NAME, ARGLIST, and BODY are the same as `defun', `defun*', `defmacro', and
,(if (eq type 'defun*)
`(cl-labels ((,@rest)) ,body)
`(cl-letf (((symbol-function #',(car rest))
(fn! ,(cadr rest) ,@(cddr rest))))
(lambda! ,(cadr rest) ,@(cddr rest))))
,body))))
(_
(when (eq (car-safe type) 'function)
@ -298,7 +298,7 @@ See `eval-if!' for details on this macro's purpose."
;;; Closure factories
(defmacro fn! (arglist &rest body)
(defmacro lambda! (arglist &rest body)
"Returns (cl-function (lambda ARGLIST BODY...))
The closure is wrapped in `cl-function', meaning ARGLIST will accept anything
`cl-defun' will. Implicitly adds `&allow-other-keys' if `&key' is present in
@ -345,7 +345,7 @@ ARGLIST."
(seq-doseq (elt data)
(doom--fn-crawl elt args)))))
(defmacro fn!! (&rest args)
(defmacro fn! (&rest args)
"Return an lambda with implicit, positional arguments.
The function's arguments are determined recursively from ARGS. Each symbol from
@ -361,7 +361,7 @@ Instead of:
you can use this macro and write:
(fn!! (if %1 %3 (cadr %*)))
(fn! (if %1 %3 (cadr %*)))
which expands to: