* Re: master 68c09c6: Better CPS conversion of multi-binding `let`
[not found] ` <20211130120405.6C5F4209FD@vcs0.savannah.gnu.org>
@ 2021-11-30 13:19 ` Stefan Monnier
2021-11-30 13:30 ` Mattias Engdegård
0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2021-11-30 13:19 UTC (permalink / raw)
To: emacs-devel; +Cc: Mattias Engdegård
> - ;; Process `let' in a helper function that transforms it into a
> - ;; let* with temporaries.
> + (`(,(or 'let 'let*) () . ,body)
> + (cps--transform-1 `(progn ,@body) next-state))
> +
> + (`(let (,binding) . ,body)
> + (cps--transform-1 `(let* (,binding) ,@body) next-state))
> +
> + ;; Transform multi-variable `let' into `let*':
> + ;; (let ((v1 e1) ... (vN eN)) BODY)
> + ;; -> (let* ((t1 e1) ... (tN eN) (v1 t1) (vN tN)) BODY)
I think this optimization can be generalized to the multi-var case by
noticing that the transformation of (vN eN) into a pair (tN eN) ... (vN tN)
is not necessary because the order of the (v1 t1) ... (vN tN) doesn't matter
so we can move (vN tN) to the beginning, right next to (tN eN) and then
merge them back.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: master 68c09c6: Better CPS conversion of multi-binding `let`
2021-11-30 13:19 ` master 68c09c6: Better CPS conversion of multi-binding `let` Stefan Monnier
@ 2021-11-30 13:30 ` Mattias Engdegård
2021-11-30 13:42 ` Stefan Monnier
0 siblings, 1 reply; 6+ messages in thread
From: Mattias Engdegård @ 2021-11-30 13:30 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
30 nov. 2021 kl. 14.19 skrev Stefan Monnier <monnier@iro.umontreal.ca>:
> I think this optimization can be generalized to the multi-var case by
> noticing that the transformation of (vN eN) into a pair (tN eN) ... (vN tN)
> is not necessary because the order of the (v1 t1) ... (vN tN) doesn't matter
> so we can move (vN tN) to the beginning, right next to (tN eN) and then
> merge them back.
Not sure how that would work unless you imply some kind of dependency analysis. Maybe you have an example in mind?
(Sorry about the incorrect git summary line, by the way -- 'multi-binding' should have been 'single-binding'.)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: master 68c09c6: Better CPS conversion of multi-binding `let`
2021-11-30 13:30 ` Mattias Engdegård
@ 2021-11-30 13:42 ` Stefan Monnier
2021-11-30 13:49 ` Mattias Engdegård
0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2021-11-30 13:42 UTC (permalink / raw)
To: Mattias Engdegård; +Cc: emacs-devel
>> I think this optimization can be generalized to the multi-var case by
>> noticing that the transformation of (vN eN) into a pair (tN eN) ... (vN tN)
>> is not necessary because the order of the (v1 t1) ... (vN tN) doesn't matter
>> so we can move (vN tN) to the beginning, right next to (tN eN) and then
>> merge them back.
>
> Not sure how that would work unless you imply some kind of dependency
> analysis. Maybe you have an example in mind?
No dependency analysis needed, just always turn
(let ((x1 e1) ... (xN eN))
BODY)
into
(let* ((t1 e1) ... (tN-1 eN-1) (xN eN) (x1 t1) .. (xN-1 tN-1))
BODY)
-- Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: master 68c09c6: Better CPS conversion of multi-binding `let`
2021-11-30 13:42 ` Stefan Monnier
@ 2021-11-30 13:49 ` Mattias Engdegård
2021-11-30 13:54 ` Stefan Monnier
0 siblings, 1 reply; 6+ messages in thread
From: Mattias Engdegård @ 2021-11-30 13:49 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
30 nov. 2021 kl. 14.42 skrev Stefan Monnier <monnier@iro.umontreal.ca>:
> (let ((x1 e1) ... (xN eN))
> BODY)
>
> into
>
> (let* ((t1 e1) ... (tN-1 eN-1) (xN eN) (x1 t1) .. (xN-1 tN-1))
> BODY)
Sorry, I should have read your original comment more carefully; I thought you meant some way of eliminating more than one temporary. Yes, that's probably a good idea. I'll see what I can do.
(That function, cps--transform-1, suffers severely from our lack of TCO by the way.)
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-11-30 14:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20211130120404.23495.29099@vcs0.savannah.gnu.org>
[not found] ` <20211130120405.6C5F4209FD@vcs0.savannah.gnu.org>
2021-11-30 13:19 ` master 68c09c6: Better CPS conversion of multi-binding `let` Stefan Monnier
2021-11-30 13:30 ` Mattias Engdegård
2021-11-30 13:42 ` Stefan Monnier
2021-11-30 13:49 ` Mattias Engdegård
2021-11-30 13:54 ` Stefan Monnier
2021-11-30 14:11 ` Mattias Engdegård
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.