Mercurial > hg > xemacs-beta
comparison man/lispref/objects.texi @ 4792:95b04754ea8c
Make #'equalp more compatible with CL; add a compiler macro, test & doc it.
lisp/ChangeLog addition:
2009-11-08 Aidan Kehoe <kehoea@parhasard.net>
* cl-extra.el (cl-string-vector-equalp)
(cl-bit-vector-vector-equalp, cl-vector-array-equalp)
(cl-hash-table-contents-equalp): New functions, to implement
equalp treating arrays with identical contents as equivalent, as
specified by Common Lisp.
(equalp): Revise this function to implement array equivalence,
and the hash-table equalp behaviour specified by CL.
* cl-macs.el (equalp): Add a compiler macro for this function,
used when one of the arguments is constant, and as such, its type
is known at compile time.
man/ChangeLog addition:
2009-11-08 Aidan Kehoe <kehoea@parhasard.net>
* lispref/objects.texi (Equality Predicates):
Document #'equalp here, as well as #'equal and #'eq.
tests/ChangeLog addition:
2009-12-31 Aidan Kehoe <kehoea@parhasard.net>
* automated/lisp-tests.el:
Test much of the functionality of equalp; add a pointer to Paul
Dietz' ANSI test suite for this function, converted to Emacs
Lisp. Not including the tests themselves in XEmacs because who
owns the copyright on the files is unclear and the GCL people
didn't respond to my queries.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Thu, 31 Dec 2009 15:09:41 +0000 |
parents | f9104f0e9b91 |
children | e6dec75ded0e |
comparison
equal
deleted
inserted
replaced
4791:ea07b60c097f | 4792:95b04754ea8c |
---|---|
2422 are the same. | 2422 are the same. |
2423 @end defun | 2423 @end defun |
2424 | 2424 |
2425 The test for equality is implemented recursively, and circular lists may | 2425 The test for equality is implemented recursively, and circular lists may |
2426 therefore cause infinite recursion (leading to an error). | 2426 therefore cause infinite recursion (leading to an error). |
2427 | |
2428 @defun equalp object1 object2 | |
2429 This function is like @code{equal}, but compares characters and strings | |
2430 case-insensitively; numbers are compared using @code{=}; arrays (that | |
2431 is, strings, bit-vectors and vectors) are regarded as being | |
2432 @code{equalp} if their contents are @code{equalp}; and | |
2433 @code{hash-tables} are @code{equalp} if their values are @code{equalp} | |
2434 and they would otherwise be @code{equal}. | |
2435 | |
2436 @code{equalp} is recursive with vectors, lists and hash-tables, but not | |
2437 with other complex types. For types without a defined @code{equalp} | |
2438 behavior, @code{equalp} behaves as @code{equal} does. | |
2439 | |
2440 @example | |
2441 @group | |
2442 (equalp "asdf" "ASDF") | |
2443 @result{} t | |
2444 @end group | |
2445 @group | |
2446 (equalp "asdf" [?a ?s ?D ?F]) | |
2447 @result{} t | |
2448 @end group | |
2449 @group | |
2450 (equalp "asdf" [?a ?s ?D ?F ?g]) | |
2451 @result{} nil | |
2452 @end group | |
2453 @group | |
2454 (equalp "" (bit-vector)) | |
2455 @result{} t | |
2456 @end group | |
2457 @group | |
2458 (equalp #s(hash-table) (make-hash-table)) | |
2459 @result{} t | |
2460 @end group | |
2461 @group | |
2462 (equalp #s(hash-table data (t "hi there")) | |
2463 (let ((ht (make-hash-table))) | |
2464 (puthash t "HI THERE" ht) | |
2465 ht)) | |
2466 @result{} t | |
2467 @group | |
2468 @end group | |
2469 (equalp #s(hash-table test eq data (1.0 "hi there")) | |
2470 (let ((ht (make-hash-table :test 'eql))) | |
2471 (puthash 1.0 "HI THERE" ht) | |
2472 ht)) | |
2473 @result{} nil | |
2474 @end group | |
2475 @end example | |
2476 @end defun | |
2477 | |
2478 @code{equalp} can also provoke an error if handed a circular structure, | |
2479 as with @code{equal}. |