help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Advantage using mapc over dolist


From: Jean Louis
Subject: Re: Advantage using mapc over dolist
Date: Tue, 3 Dec 2024 22:38:53 +0300
User-agent: Mutt/2.2.12 (2023-09-09)

* Tomas Hlavaty <tom@logand.com> [2024-12-03 18:01]:
> On Tue 03 Dec 2024 at 09:11, Stefan Monnier via Users list for the GNU Emacs 
> text editor <help-gnu-emacs@gnu.org> wrote:
> >>>           (pcase actm
> >>>            ('armg (do-this))
> >>>            ('go (do-that))))
> >>
> >> this does not justify pcase, use ecase or case instead
> >
> > That's your personal preference.
> > My own personal preference is to forget about
> > case/cl/case/ecase/cl-ecase and just use `pcase` like the author
> > already did.
> 
> I respect your preference and understand that you as pcase author would
> prefer it everywhere.  But whoever renamed case and ecase did not
> respect other peoples preferences and people are now forced to use that
> pcase monstrosity even in very simple cases.

No infection here, no monstrosity on my side, and nobody forced me
anything, in fact I have highest joy with Emacs Lisp.

I remember `dlet*' was like this:

(defmacro rcd-dlet (binders &rest body)
  "Like `let*' but using dynamic scoping.

Argument BINDERS behaves similarly like `let' with the difference
that variables become global even under lexical scope.

Optional argument BODY will be executed."
  (declare (indent 1) (debug let))
  ;; (defvar FOO) only affects the current scope, but in order for
  ;; this not to affect code after the main `let' we need to create a new scope,
  ;; which is what the surrounding `let' is for.
  ;; FIXME: (let () ...) currently doesn't actually create a new scope,
  ;; which is why we use (let (_) ...).
  `(let (_)
     ,@(mapcar (lambda (binder)
                 `(defvar ,(if (consp binder) (car binder) binder)))
               binders)
     (let* ,binders ,@body)))

but someone changed it substantially:

(defmacro dlet (binders &rest body)
  "Like `let' but using dynamic scoping."
  (declare (indent 1) (debug let))
  ;; (defvar FOO) only affects the current scope, but in order for
  ;; this not to affect code after the main `let' we need to create a new scope,
  ;; which is what the surrounding `let' is for.
  ;; FIXME: (let () ...) currently doesn't actually create a new scope,
  ;; which is why we use (let (_) ...).
  `(let (_)
     ,@(mapcar (lambda (binder)
                 `(defvar ,(if (consp binder) (car binder) binder)))
               binders)
     (let ,binders ,@body)))

That small difference was changed, and I was feeling about you:

(let* ,binders ,@body)

and I complained, because I did not realize how easy it is to make it
how I want, so I stole the function and it is done and well!

In fact, it is possible to make a package aliasing all cl- functions and it is 
done.

-- 
Jean Louis



reply via email to

[Prev in Thread] Current Thread [Next in Thread]