Mercurial > hg > xemacs-beta
comparison lisp/cl-extra.el @ 5632:bd80d9103fc8
Integrate CL code better into core, remove obsolete compatibility code.
lisp/ChangeLog addition:
2011-12-30 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp.el:
Call #'cl-compile-time-init explicitly here, don't rely on
bytecomp-load-hook for what is core functionality.
* cl-extra.el:
* cl-extra.el (require):
* cl-extra.el (make-random-state):
* cl-extra.el (random-state-p):
* cl-extra.el (make-hashtable): Removed.
* cl-extra.el (make-weak-hashtable): Removed.
* cl-extra.el (make-key-weak-hashtable): Removed.
* cl-extra.el (make-value-weak-hashtable): Removed.
* cl-extra.el ('hashtablep): Removed.
* cl-extra.el ('hashtable-fullness): Removed.
* cl-extra.el ('hashtable-test-function): Removed.
* cl-extra.el ('hashtable-type): Removed.
* cl-extra.el ('hashtable-size): Removed.
* cl-extra.el ('copy-hashtable): Removed.
* cl-extra.el (cl-builtin-gethash): Removed.
* cl-extra.el (cl-builtin-remhash): Removed.
* cl-extra.el (cl-builtin-clrhash): Removed.
* cl-extra.el (cl-builtin-maphash): Removed.
* cl-extra.el ('cl-gethash): Removed.
* cl-extra.el ('cl-puthash): Removed.
* cl-extra.el ('cl-remhash): Removed.
* cl-extra.el ('cl-clrhash): Removed.
* cl-extra.el ('cl-maphash): Removed.
* cl-extra.el ('cl-make-hash-table): Removed.
* cl-extra.el ('cl-hash-table-p): Removed.
* cl-extra.el ('cl-hash-table-count): Removed.
* cl-extra.el (cl-prettyexpand):
* cl-extra.el (names):
Remove compatibility aliases from this file.
In #'cl-prettyexpand, if FULL is nil, don't expand return-from
either, for symmetry with not expanding block.
Drop cl-extra-load-hook, it's useless when cl-extra is dumped
(since third-party code can't use it, and dumped code shouldn't
use it.)
* cl-macs.el:
* cl-macs.el (cl-pop2):
* cl-macs.el (defun*):
* cl-macs.el (cl-parse-loop-clause):
Remove some no-longer-needed compatibility kludges.
* cl.el:
* cl.el ('cl-map-extents): Removed.
* cl.el (cl-random-time):
* cl.el (list*): New, moved back from subr.el, given a shorter
implementation.
* cl.el ('cl-member): Removed.
* cl.el ('cl-floor): Removed.
* cl.el ('cl-ceiling): Removed.
* cl.el ('cl-truncate): Removed.
* cl.el ('cl-round): Removed.
* cl.el ('cl-mod): Removed.
Remove some compatibility aliases; these may conflict with
package usage, in which case the packages need to be updated, the
new names are available in 21.4, and that's the most recent
version we support.
* cl.el (cl-hacked-flag): Removed.
* cl.el (cl-hack-byte-compiler): Removed.
* subr.el:
* subr.el (list*): Moved back to cl.el.
* update-elc-2.el (batch-update-elc-2):
* update-elc.el (do-autoload-commands):
Add an autoload for cl-compile-time-init in these two files, they
run on bare temacs, auto-autoload isn't available to them, and now
bytecomp calls cl-compile-time-init explicitly.
* cl-compat.el: Removed. This file was long obsolete.
man/ChangeLog addition:
2011-12-30 Aidan Kehoe <kehoea@parhasard.net>
* cl.texi (Top):
* cl.texi (Usage):
* cl.texi (Organization):
* cl.texi (Efficiency Concerns):
* cl.texi (Common Lisp Compatibility):
Remove documentation of cl-compat, now it's deleted.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Fri, 30 Dec 2011 16:05:31 +0000 |
parents | 10f179710250 |
children | e9c3fe82127d |
comparison
equal
deleted
inserted
replaced
5631:5e256f495401 | 5632:bd80d9103fc8 |
---|---|
44 ;; See cl.el for Change Log. | 44 ;; See cl.el for Change Log. |
45 | 45 |
46 | 46 |
47 ;;; Code: | 47 ;;; Code: |
48 ;; XEmacs addition | 48 ;; XEmacs addition |
49 (eval-when-compile | 49 (eval-when-compile (require 'obsolete)) |
50 (require 'obsolete)) | |
51 | 50 |
52 ;;; Type coercion. | 51 ;;; Type coercion. |
53 | 52 |
54 (defun coerce (object type) | 53 (defun coerce (object type) |
55 "Coerce OBJECT to type TYPE. | 54 "Coerce OBJECT to type TYPE. |
352 | 351 |
353 (defun make-random-state (&optional state) | 352 (defun make-random-state (&optional state) |
354 "Return a copy of random-state STATE, or of `*random-state*' if omitted. | 353 "Return a copy of random-state STATE, or of `*random-state*' if omitted. |
355 If STATE is t, return a new state object seeded from the time of day." | 354 If STATE is t, return a new state object seeded from the time of day." |
356 (cond ((null state) (make-random-state *random-state*)) | 355 (cond ((null state) (make-random-state *random-state*)) |
357 ((vectorp state) (cl-copy-tree state t)) | 356 ((vectorp state) (copy-tree state t)) |
358 ((integerp state) (vector 'cl-random-state-tag -1 30 state)) | 357 ((integerp state) (vector 'cl-random-state-tag -1 30 state)) |
359 (t (make-random-state (cl-random-time))))) | 358 (t (make-random-state (cl-random-time))))) |
360 | 359 |
361 (defun random-state-p (object) | 360 (defun random-state-p (object) |
362 "Return t if OBJECT is a random-state object." | 361 "Return t if OBJECT is a random-state object." |
363 (and (vectorp object) (= (length object) 4) | 362 (and (vectorp object) (eql (length object) 4) |
364 (eq (aref object 0) 'cl-random-state-tag))) | 363 (eq (aref object 0) 'cl-random-state-tag))) |
365 | 364 |
366 ;;; Sequence functions. | 365 ;;; Sequence functions. |
367 | 366 |
368 ;; XEmacs; #'subseq is in C. | 367 ;; XEmacs; #'subseq is in C. |
450 t | 449 t |
451 "Our assumptions about compiled code appear not to hold.") | 450 "Our assumptions about compiled code appear not to hold.") |
452 (compiled-function-instructions compiled))) | 451 (compiled-function-instructions compiled))) |
453 (vector value) 1)))) | 452 (vector value) 1)))) |
454 | 453 |
455 ;;; Hash tables. | 454 ;;; Hash tables. XEmacs; remove the compatibility stuff, which was all that |
456 | 455 ;;; remained here, given the hash table implementation is in C. |
457 ;; The `regular' Common Lisp hash-table stuff has been moved into C. | |
458 ;; Only backward compatibility stuff remains here. | |
459 (defun make-hashtable (size &optional test) | |
460 (make-hash-table :test test :size size)) | |
461 (defun make-weak-hashtable (size &optional test) | |
462 (make-hash-table :test test :size size :weakness t)) | |
463 (defun make-key-weak-hashtable (size &optional test) | |
464 (make-hash-table :test test :size size :weakness 'key)) | |
465 (defun make-value-weak-hashtable (size &optional test) | |
466 (make-hash-table :test test :size size :weakness 'value)) | |
467 | |
468 (define-obsolete-function-alias 'hashtablep 'hash-table-p) | |
469 (define-obsolete-function-alias 'hashtable-fullness 'hash-table-count) | |
470 (define-obsolete-function-alias 'hashtable-test-function 'hash-table-test) | |
471 (define-obsolete-function-alias 'hashtable-type 'hash-table-type) | |
472 (define-obsolete-function-alias 'hashtable-size 'hash-table-size) | |
473 (define-obsolete-function-alias 'copy-hashtable 'copy-hash-table) | |
474 | |
475 (make-obsolete 'make-hashtable 'make-hash-table) | |
476 (make-obsolete 'make-weak-hashtable 'make-hash-table) | |
477 (make-obsolete 'make-key-weak-hashtable 'make-hash-table) | |
478 (make-obsolete 'make-value-weak-hashtable 'make-hash-table) | |
479 (make-obsolete 'hash-table-type 'hash-table-weakness) | |
480 | |
481 (when (fboundp 'x-keysym-hash-table) | |
482 (make-obsolete 'x-keysym-hashtable 'x-keysym-hash-table)) | |
483 | |
484 ;; Compatibility stuff for old kludgy cl.el hash table implementation | |
485 (defvar cl-builtin-gethash (symbol-function 'gethash)) | |
486 (defvar cl-builtin-remhash (symbol-function 'remhash)) | |
487 (defvar cl-builtin-clrhash (symbol-function 'clrhash)) | |
488 (defvar cl-builtin-maphash (symbol-function 'maphash)) | |
489 | |
490 (defalias 'cl-gethash 'gethash) | |
491 (defalias 'cl-puthash 'puthash) | |
492 (defalias 'cl-remhash 'remhash) | |
493 (defalias 'cl-clrhash 'clrhash) | |
494 (defalias 'cl-maphash 'maphash) | |
495 ;; These three actually didn't exist in Emacs-20. | |
496 (defalias 'cl-make-hash-table 'make-hash-table) | |
497 (defalias 'cl-hash-table-p 'hash-table-p) | |
498 (defalias 'cl-hash-table-count 'hash-table-count) | |
499 | 456 |
500 ;;; Some debugging aids. | 457 ;;; Some debugging aids. |
501 | 458 |
502 (defun cl-prettyprint (form) | 459 (defun cl-prettyprint (form) |
503 "Insert a pretty-printed rendition of a Lisp FORM in current buffer." | 460 "Insert a pretty-printed rendition of a Lisp FORM in current buffer." |
641 (defun cl-prettyexpand (form &optional full) | 598 (defun cl-prettyexpand (form &optional full) |
642 (message "Expanding...") | 599 (message "Expanding...") |
643 (let ((cl-macroexpand-cmacs full) (cl-compiling-file full) | 600 (let ((cl-macroexpand-cmacs full) (cl-compiling-file full) |
644 (byte-compile-macro-environment nil)) | 601 (byte-compile-macro-environment nil)) |
645 (setq form (cl-macroexpand-all form | 602 (setq form (cl-macroexpand-all form |
646 (and (not full) '((block) (eval-when))))) | 603 (and (not full) |
604 '((block) (return-from) (eval-when))))) | |
647 (message "Formatting...") | 605 (message "Formatting...") |
648 (prog1 (cl-prettyprint form) | 606 (prog1 (cl-prettyprint form) |
649 (message "")))) | 607 (message "")))) |
650 | 608 |
651 ;; XEmacs addition; force cl-macs to be available from here on when | 609 ;; XEmacs addition; force cl-macs to be available from here on when |
826 (unicode-to-char (string-to-number (subseq name 1) 16)) | 784 (unicode-to-char (string-to-number (subseq name 1) 16)) |
827 (with-current-buffer (get-buffer-create " *Unicode Data*") | 785 (with-current-buffer (get-buffer-create " *Unicode Data*") |
828 (require 'descr-text) | 786 (require 'descr-text) |
829 (when (zerop (buffer-size)) | 787 (when (zerop (buffer-size)) |
830 ;; Don't use -literally in case of DOS line endings. | 788 ;; Don't use -literally in case of DOS line endings. |
831 (insert-file-contents describe-char-unicodedata-file)) | 789 (insert-file-contents |
790 (declare-boundp describe-char-unicodedata-file))) | |
832 (goto-char (point-min)) | 791 (goto-char (point-min)) |
833 (setq case-fold-search nil) | 792 (setq case-fold-search nil) |
834 (and (re-search-forward (format #r"^\([0-9A-F]\{4,6\}\);%s;" | 793 (and (re-search-forward (format #r"^\([0-9A-F]\{4,6\}\);%s;" |
835 (upcase (replace-in-string | 794 (upcase (replace-in-string |
836 name "_" " " t))) nil t) | 795 name "_" " " t))) nil t) |
896 (defalias 'remassq | 855 (defalias 'remassq |
897 #'(lambda (key alist) | 856 #'(lambda (key alist) |
898 (delete* key alist :test #'eq | 857 (delete* key alist :test #'eq |
899 :key (if key #'car-safe #'car-or-not-nil)))))) | 858 :key (if key #'car-safe #'car-or-not-nil)))))) |
900 | 859 |
901 (run-hooks 'cl-extra-load-hook) | 860 ;; XEmacs; since cl-extra.el is dumped, cl-extra-load-hook is |
861 ;; useless. (Dumped files normally shouldn't be using hooks, functionality | |
862 ;; should be implemented explicitly.) | |
902 | 863 |
903 ;; XEmacs addition | 864 ;; XEmacs addition |
904 (provide 'cl-extra) | 865 (provide 'cl-extra) |
905 | 866 |
906 ;;; arch-tag: bcd03437-0871-43fb-a8f1-ad0e0b5427ed | 867 ;;; arch-tag: bcd03437-0871-43fb-a8f1-ad0e0b5427ed |