emacs-pretest-bug
[Top][All Lists]
Advanced

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

Re: CC mode loads CL


From: Luc Teirlinck
Subject: Re: CC mode loads CL
Date: Sat, 17 Jan 2004 21:55:29 -0600 (CST)

Richard Stallman wrote:

   If the existence of multiple equivalent functions bothers people,
   I would rather install a function delq-duplicates that compares
   using eq.  That fits the spirit of Emacs Lisp.

I have no strong personal opinions on this.  Just trying to float some
ideas around:

I personally believe that using `equal' as test is more useful than
`eq'.  All current uses I am aware of in the Emacs code use `equal' as
test.  I see two possibilities:

1. Use a function of one argument, the list, and `equal' as test.

2. Use a function of two arguments, one required, the list, and one
   optional, the test, defaulting to `equal'.

Either way, we could use a name such as, say, `delete-repeats' to make
clear that the function is not identical with the CL function
`delete-duplicates', and avoid a name clash.

If we go for (1), then maybe we could just rename
`mm-delete-duplicates', rewrite its docstring, and move it from
mm-util.el into subr.el or some similar place:

(defun mm-delete-duplicates (list)
  "Simple substitute for CL `delete-duplicates', testing with `equal'."
  (let (result head)
    (while list
      (setq head (car list))
      (setq list (delete head list))
      (setq result (cons head result)))
    (nreverse result)))

Some people might stylistically prefer:

(push head result) over: (setq result (cons head result)),

and maybe we should make that change, but that is just an unimportant
detail.

Even (2) should produce a function whose code is substantially simpler
and more transparent than `cl-delete-duplicates'.

Sincerely,

Luc.





reply via email to

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