emacs-devel
[Top][All Lists]
Advanced

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

Re: Lisp files that load cl-lib in problematical ways


From: Stefan Kangas
Subject: Re: Lisp files that load cl-lib in problematical ways
Date: Wed, 25 Oct 2023 00:57:29 -0700

Richard Stallman <rms@gnu.org> writes:

> But if we let ourselves be a little more flexible, how about this
> solution: install this
>
>         (while (string-match "\\W" abbrev pos)
>           (or (memq (aref abbrev (match-beginning 0)) badchars)
>               (push (aref abbrev (match-beginning 0)) badchars))
>           (setq pos (1+ pos)))
>
> instead of the current code:
>
>         (while (string-match "\\W" abbrev pos)
>           (cl-pushnew (aref abbrev (match-beginning 0)) badchars)
>           (setq pos (1+ pos)))
>
> A CL fan might say the latter is simpler, but for me, who isn't sure
> just how to use cl-pushnew, the former seems conceptually simpler.

The `cl-pushnew' docstring explains:

    Add X to the list stored in PLACE unless X is already in the list.

> The two ecxpressions have two different kinds of complexity.

The only difference I see is that new version is harder to read, and
more prone to bugs (as you have to write the same code twice).

I'd suggest avoiding these types of changes.



reply via email to

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