(defmacro lets ((&rest substs) &body body)
"Did someone write let-but-its-substs already? #commonLisp #macro #programming "
(loop
:for body1 := body :then body2
:for body2
:=
(loop
:for new-body := body1
:then (subst new old new-body :test 'equal)
:for (old new) :in substs
:finally (return new-body))
:when (equal body1 body2)
:return (append '(progn) body1)))
Conversation
Notices
-
Embed this notice
screwlisp (screwtape@mastodon.sdf.org)'s status on Thursday, 09-Jan-2025 16:48:51 JST screwlisp
-
Embed this notice
screwlisp (screwtape@mastodon.sdf.org)'s status on Friday, 10-Jan-2025 04:46:30 JST screwlisp
@Ardubal that's what I thought too.
Then I floundered with macroexpand-1 a bit, and thought maybe I just wanted a conventional macro that does substs on body. Otherwise I would have to think about the read-table
Interestingly this means the left half doesn't have to be a symbol.
-
Embed this notice
Svante (ardubal@mastodon.xyz)'s status on Friday, 10-Jan-2025 04:46:31 JST Svante
@screwtape I am not sure, but all the use cases that I can think of here could probably be handled by macrolet and symbol-macrolet.
-
Embed this notice