emacs-devel
[Top][All Lists]
Advanced

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

Re: lengths and other stuff


From: Tomas Hlavaty
Subject: Re: lengths and other stuff
Date: Mon, 28 Dec 2020 00:25:32 +0100

On Sun 27 Dec 2020 at 15:05, Daniel Brooks <db48x@db48x.net> wrote:
> Some of them can no doubt be replaced by multiple-value-bind and other
> such things. This one from ido.el:1518, for example:
>
>     (if (and (listp (car l))
>              (> (length (car l)) 2)
>              (let ((dir (car (car l)))
>                    (time (car (cdr (car l))))
>                    (files (cdr (cdr (car l)))))
>
> could be (multiple-value-bind (dir time files) (car l) …).
>
> But those kinds of improvements take a lot more thought about each
> occurrence.

Very good.  Now the other ~1700 cases.

I think you introduced two bugs:

1) missing &rest, it should be:

   (multiple-value-bind (dir time &rest files) (car l) …)

2) multiple-value-bind throws an error if it does not fit.  The original
   code does not seem to throw an error.

But all this excercise for single case took mental effort, got it wrong
and the change would need to be carefully undertaken.

The point of the predicates is to avoid such rewrites and improve the
code simply by search, replace and visual substitution without thinking
hard and introducing bugs.



reply via email to

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