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

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

Re: member returns list


From: Emanuel Berg
Subject: Re: member returns list
Date: Sun, 06 Sep 2015 04:57:16 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Random832 <random832@fastmail.com> writes:

> How is this different from memq itself
> appearing repeatedly?

`memq' is a function. What should not be repeated is
data (in your case the a function passed as an
argument).

> Or the substring -eq appearing repeatedly in your
> version in symbols like member-eq and assoc-eq?

Those are not my versions. I made the examples to show
how it could look. It doesn't, which is good.

> It's just like using a naming convention, only it
> makes it possible (and obvious that it is possible)
> to substitute the comparison function with your own
> function. It's simpler because instead of having two
> functions to do two things with no obvious way to do
> the same thing with anything else, you have one
> function that can easily discoverably do anything.

There should be one function that can do everything
but common patterns should be factored out into
interfaces and/or optimizations.

Code shouldn't look like this:

    (do-this 1 2 3)
    (do-this 1 2 3)
    (do-this 1 2 3)

But like this:

    (defun do-the-one-two-three-thing ()
      (do-this 1 2 3) )

    (loop repeat 3 do (do-the-one-two-three-thing))

-- 
underground experts united
http://user.it.uu.se/~embe8573




reply via email to

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