diff lisp/cl.el @ 5219:2d0937dc83cf

Tidying of CL files; make docstrings read better, remove commented-out code 2010-05-30 Aidan Kehoe <kehoea@parhasard.net> * cl.el: Remove extraneous empty lines. Remove the commented-out Lisp implementation of #'last, #'copy-list. Remove #'cl-maclisp-member. (acons, pairlis): Have the argument list reflect the docstring for these functions. * cl-macs.el (defun*): Have the argument list reflect the docstring. Document the syntax of keywords in ARGLIST. (defmacro*): Have the argument list reflect the docstring. Document &body, &whole and &environment. (function*): Have the argument list reflect the docstring. (loop): Have the argument list reflect the docstring. (eval-when, dolist, dotimes, do-symbols, flet, labels, macrolet, symbol-macrolet): Specify the argument list using the arguments: (...) syntax. (define-setf-method, rotatef, defsubst*): Have the argument list reflect the docstring. (letf, letf*): Specify the argument list using the arguments: (...) syntax. (svref, acons, pairlis): Add compiler macros for these functions. * cl-extra.el: Remove the commented-out Lisp implementation of #'equalp. If we want to look at it, it's in version control. (cl-expt): Remove this. The subr #'expt is always available. Call #'cl-float-limits at dump time. Remove the commented-out Lisp implementation of #'subseq. (concatenate): Use (error 'invalid-argument ...) here, if TYPE is not understood. (list-length): Don't manually get the length of a list, call #'length and return nil if the list is circular. * byte-optimize.el (equalp): This needs byte-optimize-binary-predicate as its optimizer, as do the other equality predicates.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 30 May 2010 13:27:36 +0100
parents 545ec923b4eb
children aa20a889ff14 308d34e9f07d
line wrap: on
line diff
--- a/lisp/cl.el	Sat May 29 15:19:54 2010 +0100
+++ b/lisp/cl.el	Sun May 30 13:27:36 2010 +0100
@@ -99,17 +99,9 @@
 
 ;;; Code:
 
-(defvar cl-emacs-type (cond ((or (and (fboundp 'epoch::version)
-				      (symbol-value 'epoch::version))
-				 (string-lessp emacs-version "19")) 18)
-			    ((string-match "XEmacs" emacs-version)
-			     'lucid)
-			    (t 19)))
-
 (defvar cl-optimize-speed 1)
 (defvar cl-optimize-safety 1)
 
-
 (defvar custom-print-functions nil
   "This is a list of functions that format user objects for printing.
 Each function is called in turn with three arguments: the object, the
@@ -120,7 +112,6 @@
 This variable is not used at present, but it is defined in hopes that
 a future Emacs interpreter will be able to use it.")
 
-
 ;;; Predicates.
 
 (defun eql (a b)    ; See compiler macro in cl-macs.el
@@ -206,7 +197,6 @@
 	  val
 	  (and (< end (length str)) (substring str end))))
 
-
 ;;; Control structures.
 
 ;; The macros `when' and `unless' are so useful that we want them to
@@ -215,7 +205,6 @@
 
 (defalias 'cl-map-extents 'map-extents)
 
-
 ;;; Blocks and exits.
 
 ;; This used to be #'identity, but that didn't preserve multiple values in
@@ -260,7 +249,6 @@
       (setq cl-macro (cadr (assq (symbol-name cl-macro) cl-env))))
     cl-macro))
 
-
 ;;; Declarations.
 
 (defvar cl-compiling-file nil)
@@ -289,7 +277,6 @@
     (if (cl-compiling-file) (list* 'eval-when '(compile load eval) body)
       (cons 'progn body))))   ; avoid loading cl-macs.el for eval-when
 
-
 ;;; Symbols.
 
 (defun cl-random-time ()
@@ -363,12 +350,13 @@
 (defconst float-epsilon nil)
 (defconst float-negative-epsilon nil)
 
-
 ;;; Sequence functions.
 
 (defalias 'copy-seq 'copy-sequence)
 
-(defalias 'svref 'aref)
+;; XEmacs; #'mapcar* is in C.
+
+(defalias 'svref 'aref) ;; Compiler macro in cl-macs.el
 
 ;;; List functions.
 
@@ -530,16 +518,6 @@
   (cdr (cdr (cdr (cdr x)))))
 
 ;;; `last' is implemented as a C primitive, as of 1998-11
-;;(defun last* (x &optional n)
-;;  "Returns the last link in the list LIST.
-;;With optional argument N, returns Nth-to-last link (default 1)."
-;;  (if n
-;;      (let ((m 0) (p x))
-;;	(while (consp p) (incf m) (pop p))
-;;	(if (<= n 0) p
-;;	  (if (< n m) (nthcdr (- m n) x) x)))
-;;    (while (consp (cdr x)) (pop x))
-;;    x))
 
 (defun list* (arg &rest rest)   ; See compiler macro in cl-macs.el
   "Return a new list with specified args as elements, cons'd to last arg.
@@ -562,19 +540,6 @@
 
 ;;; `copy-list' is implemented as a C primitive, as of 1998-11
 
-;(defun copy-list (list)
-;  "Return a copy of a list, which may be a dotted list.
-;The elements of the list are not copied, just the list structure itself."
-;  (if (consp list)
-;      (let ((res nil))
-;	(while (consp list) (push (pop list) res))
-;	(prog1 (nreverse res) (setcdr res list)))
-;    (car list)))
-
-(defun cl-maclisp-member (item list)
-  (while (and list (not (equal item (car list)))) (setq list (cdr list)))
-  list)
-
 (defalias 'cl-member 'memq)   ; for compatibility with old CL package
 (defalias 'cl-floor 'floor*)
 (defalias 'cl-ceiling 'ceiling*)
@@ -612,12 +577,16 @@
 	       cl-tree (cons a d))))
 	(t cl-tree)))
 
-(defun acons (a b c)
+(defun acons (key value alist)
   "Return a new alist created by adding (KEY . VALUE) to ALIST."
-  (cons (cons a b) c))
+  (cons (cons key value) alist))
 
-(defun pairlis (a b &optional c) (nconc (mapcar* 'cons a b) c))
-
+(defun pairlis (keys values &optional alist)
+  "Make an alist from KEYS and VALUES.
+Return a new alist composed by associating KEYS to corresponding VALUES;
+the process stops as soon as KEYS or VALUES run out.
+If ALIST is non-nil, the new pairs are prepended to it."
+  (nconc (mapcar* 'cons keys values) alist))
 
 ;;; Miscellaneous.
 
@@ -667,10 +636,8 @@
    ((loop) defun (&rest &or symbolp form))
    ((ignore-errors) 0 (&rest form))))
 
-
 ;;; This goes here so that cl-macs can find it if it loads right now.
-(provide 'cl-19)     ; usage: (require 'cl-19 "cl")
-
+(provide 'cl-19)
 
 ;;; Things to do after byte-compiler is loaded.
 ;;; As a side effect, we cause cl-macs to be loaded when compiling, so