emacs-devel
[Top][All Lists]
Advanced

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

lengths and other stuff


From: Daniel Brooks
Subject: lengths and other stuff
Date: Sun, 27 Dec 2020 15:05:59 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

Tomas Hlavaty <tom@logand.com> writes:

> On Sun 27 Dec 2020 at 17:49, "Alfred M. Szmidt" <ams@gnu.org> wrote:
>>    However, if somebody writes such code, it is almost trivial to fix
>>    it with search and replace:
>>
>>       "(= (length" -> "(length="
>>       "(< (length" -> "(length<"
>>       "(> (length" -> "(length>"
>>       "(/= (length" -> "(length/="
>>       "(<= (length" -> "(length<="
>>       "(>= (length" -> "(length>="
>>
>>    (plus extra closing paren)
>>
>> Users will assume that these length>= hacks will make their code
>> magically better, when they just hide a problematic form -- doing a
>> possibly complicated operation inside a predicate call.
>
> It will make their code better.  I do not see any magic there, it is
> pretty simple and logical.
>
> Do you have some other solution on mind?

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.

Incidentally, I find it hard to believe that someone typed all of that
out without at least using cadar and cddar.

db48x



reply via email to

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