* About equality in Emacs
@ 2013-02-03 15:01 Xue Fuqiao
0 siblings, 0 replies; 6+ messages in thread
From: Xue Fuqiao @ 2013-02-03 15:01 UTC (permalink / raw)
To: help-gnu-emacs
In the trunk version of (info "(cl) Equality Predicates"):
Also note that the Common Lisp functions `member' and `assoc' use
`eql' to compare elements, whereas Emacs Lisp follows the MacLisp
tradition and uses `equal' for these two functions. In Emacs, use
`memq' (or `cl-member') and `assq' (or `cl-assoc') to get functions
which use `eql' for comparisons.
I'm confused with the last sentence. Don't `memq' and `assq' compare
objects with `eq'? Why does the manual say that they "get functions
which use `eql' for comparisons"?
--
Best regards, Xue Fuqiao.
http://www.emacswiki.org/emacs/XueFuqiao
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: About equality in Emacs
[not found] <mailman.18912.1359903712.855.help-gnu-emacs@gnu.org>
@ 2013-02-03 16:22 ` Pascal J. Bourguignon
2013-02-03 16:58 ` Michael Heerdegen
[not found] ` <mailman.18922.1359910610.855.help-gnu-emacs@gnu.org>
2 siblings, 0 replies; 6+ messages in thread
From: Pascal J. Bourguignon @ 2013-02-03 16:22 UTC (permalink / raw)
To: help-gnu-emacs
Xue Fuqiao <xfq.free@gmail.com> writes:
> In the trunk version of (info "(cl) Equality Predicates"):
>
> Also note that the Common Lisp functions `member' and `assoc' use
> `eql' to compare elements, whereas Emacs Lisp follows the MacLisp
> tradition and uses `equal' for these two functions. In Emacs, use
> `memq' (or `cl-member') and `assq' (or `cl-assoc') to get functions
> which use `eql' for comparisons.
>
> I'm confused with the last sentence. Don't `memq' and `assq' compare
> objects with `eq'?
Perhaps. But in Common Lisp, it would be EQL, since (eq 1 1) or (eq #\a
#\a) can return NIL. (member 1 '(1 2 3) :test (function eq)) is not
conforming in Common Lisp.
In emacs lisp, the difference between eq and eql is for floating point
numbers, where (eq 1.0 1.0) --> nil while (eql 1.0 1.0) --> t
In emacs-version "24.2.1":
(memq 1 '(1 2)) --> (1 2)
(memq 1.0 '(1.0 2.0)) --> nil
memq uses eq, so it's no good on floating point numbers.
> Why does the manual say that they "get functions
> which use `eql' for comparisons"?
The sentence is: "In Emacs, use `memq' (or `cl-member') and `assq' (or
`cl-assoc') to get functions which use `eql' for comparisons."
The original sentence was: "In Emacs, use `member*' and `assoc*' to get
functions which use `eql' for comparisons."
The original meant that if you want to compare with eql, then instead of
using member or assoc, you would use member* and assoc*.
The new version indeed is hard to understand. Does it mean that memq
and assq now use eql? I'd be surprised if it did.
New emacs: Old emacs:
memq assq ? eq memq assq
member assoc equal member assoc
cl-member cl-assoc eql member* assoc*
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: About equality in Emacs
[not found] <mailman.18912.1359903712.855.help-gnu-emacs@gnu.org>
2013-02-03 16:22 ` About equality in Emacs Pascal J. Bourguignon
@ 2013-02-03 16:58 ` Michael Heerdegen
[not found] ` <mailman.18922.1359910610.855.help-gnu-emacs@gnu.org>
2 siblings, 0 replies; 6+ messages in thread
From: Michael Heerdegen @ 2013-02-03 16:58 UTC (permalink / raw)
To: help-gnu-emacs
Xue Fuqiao <xfq.free@gmail.com> writes:
> In the trunk version of (info "(cl) Equality Predicates"):
>
> Also note that the Common Lisp functions `member' and `assoc' use
> `eql' to compare elements, whereas Emacs Lisp follows the MacLisp
> tradition and uses `equal' for these two functions. In Emacs, use
> `memq' (or `cl-member') and `assq' (or `cl-assoc') to get functions
> which use `eql' for comparisons.
>
> I'm confused with the last sentence. Don't `memq' and `assq' compare
> objects with `eq'? Why does the manual say that they "get functions
> which use `eql' for comparisons"?
Doesn't make much sense to me as well. I filed a bug report; it's now
bug#13620. I think this sentence was just damaged when it was updated.
Regards,
Michael.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: About equality in Emacs
[not found] <mailman.193.1359910844.12660.help-gnu-emacs@gnu.org>
@ 2013-02-04 0:20 ` Xue Fuqiao
2013-02-04 0:27 ` Drew Adams
0 siblings, 1 reply; 6+ messages in thread
From: Xue Fuqiao @ 2013-02-04 0:20 UTC (permalink / raw)
To: help-gnu-emacs
On Sun, 03 Feb 2013 12:00:44 -0500
Pascal J. Bourguignon wrote:
> Perhaps. But in Common Lisp, it would be EQL, since (eq 1 1) or (eq #\a
> #\a) can return NIL. (member 1 '(1 2 3) :test (function eq)) is not
> conforming in Common Lisp.
Thanks for your reply, it is a bug and it will be fixed in GNU Emacs 24.2.93. BTW, What does `#\a' mean?
--
Best regards, Xue Fuqiao.
http://www.emacswiki.org/emacs/XueFuqiao
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: About equality in Emacs
2013-02-04 0:20 ` Xue Fuqiao
@ 2013-02-04 0:27 ` Drew Adams
0 siblings, 0 replies; 6+ messages in thread
From: Drew Adams @ 2013-02-04 0:27 UTC (permalink / raw)
To: 'Xue Fuqiao', help-gnu-emacs
> What does `#\a' mean?
That's Common Lisp character syntax, in this case for the character `a' (?a in
Emacs Lisp).
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: About equality in Emacs
[not found] ` <mailman.18922.1359910610.855.help-gnu-emacs@gnu.org>
@ 2013-02-04 13:59 ` Michael Heerdegen
0 siblings, 0 replies; 6+ messages in thread
From: Michael Heerdegen @ 2013-02-04 13:59 UTC (permalink / raw)
To: help-gnu-emacs
Michael Heerdegen <michael_heerdegen@web.de> writes:
> > I'm confused with the last sentence. Don't `memq' and `assq' compare
> > objects with `eq'? Why does the manual say that they "get functions
> > which use `eql' for comparisons"?
>
> Doesn't make much sense to me as well. I filed a bug report; it's now
> bug#13620. I think this sentence was just damaged when it was updated.
Has already been fixed by Glenn Morris. This is the new version of the
paragraph:
,----------------------------------------------------------------------
| Also note that the Common Lisp functions `member' and `assoc' use
| `eql' to compare elements, whereas Emacs Lisp follows the MacLisp
| tradition and uses `equal' for these two functions. The functions
| `cl-member' and `cl-assoc' use `eql', as in Common Lisp. The standard
| Emacs Lisp functions `memq' and `assq' use `eq', so you can use these
| if you do not care about the difference between `eq' and `eql'.
|
`----------------------------------------------------------------------
Thanks Xue for finding this.
Regards,
Michael.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-02-04 13:59 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.18912.1359903712.855.help-gnu-emacs@gnu.org>
2013-02-03 16:22 ` About equality in Emacs Pascal J. Bourguignon
2013-02-03 16:58 ` Michael Heerdegen
[not found] ` <mailman.18922.1359910610.855.help-gnu-emacs@gnu.org>
2013-02-04 13:59 ` Michael Heerdegen
[not found] <mailman.193.1359910844.12660.help-gnu-emacs@gnu.org>
2013-02-04 0:20 ` Xue Fuqiao
2013-02-04 0:27 ` Drew Adams
2013-02-03 15:01 Xue Fuqiao
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.