[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Add cl-map-into
From: |
Stefan Monnier |
Subject: |
Re: [PATCH] Add cl-map-into |
Date: |
Mon, 27 Sep 2021 13:18:09 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> Absense of Common Lisp's map-into in cl-lib is an unfortunate omission.
[ As someone who likes to avoid side-effects, I have a slightly different
opinion ;-) ]
> The proposed patch adds it.
Looks pretty good. I have a code suggestion below, but my main
comments would be:
- Could you provide some corresponding tests for test/emacs-lisp/cl-tests.el?
- Since we're (weakly) promoting seq.el over cl-lib.el, I wonder if you
think it would be worthwhile to try and do something similar in seq.el?
> + (or (and small basic-cache)
> + (and (not small) general-cache)
> + (let ((mapper (cl--make-map-into-mapper sig)))
> + (if small (setf basic-cache mapper)
> + (setf general-cache mapper))))))
This can turn into
(or (if small basic-cache general-cache)
(let ((mapper (cl--make-map-into-mapper sig)))
(setf (if small basic-cache general-cache)
mapper)))
AKA
(or (if small basic-cache general-cache)
(setf (if small basic-cache general-cache)
(cl--make-map-into-mapper sig)))
which thus looks very much like what I used in
`cl--generic-with-memoization`, so you could replace the symbol-macrolet
with something like:
(cl--generic-with-memoization
(if small
(aref cl--map-into-mappers-array sig)
;; TODO: Order alist entries for faster lookup
;; (note that we'll have to abandon alist-get then).
(alist-get sig cl--map-into-mappers-alist nil nil #'=))
(cl--make-map-into-mapper sig))
-- Stefan
- [PATCH] Add cl-map-into, akater, 2021/09/23
- Re: [PATCH] Add cl-map-into,
Stefan Monnier <=
- Re: [PATCH] Add cl-map-into, akater, 2021/09/29
- Re: [PATCH] Add cl-map-into, Stefan Monnier, 2021/09/29
- Re: [PATCH] Add cl-map-into, Bozhidar Batsov, 2021/09/30
- Re: [PATCH] Add cl-map-into, Adam Porter, 2021/09/30
- Re: [PATCH] Add cl-map-into, Bozhidar Batsov, 2021/09/30
- Re: [PATCH] Add cl-map-into, Adam Porter, 2021/09/30
- Re: [PATCH] Add cl-map-into, akater, 2021/09/30