This variable is not used at present, but it is defined in hopes that
a future Emacs interpreter will be able to use it.")
+(defvar cl-unload-hook '(cl-cannot-unload)
+ "Prevent unloading the feature `cl', since it does not work.")
+(defun cl-cannot-unload ()
+ (error "Cannot unload the feature `cl'"))
;;; Predicates.
(defun cl-set-substring (str start end val)
(if end (if (< end 0) (incf end (length str)))
(setq end (length str)))
- (if (< start 0) (incf start str))
+ (if (< start 0) (incf start (length str)))
(concat (and (> start 0) (substring str 0 start))
val
(and (< end (length str)) (substring str end))))
;;; simulated. Instead, multiple-value-bind and friends simply expect
;;; the target form to return the values as a list.
-(defalias 'values 'list)
-(defalias 'values-list 'identity)
-(defalias 'multiple-value-list 'identity)
-(defalias 'multiple-value-call 'apply) ; only works for one arg
-(defalias 'nth-value 'nth)
+(defsubst values (&rest values)
+ "Return multiple values, Common Lisp style.
+The arguments of `values' are the values
+that the containing function should return."
+ values)
+(defsubst values-list (list)
+ "Return multiple values, Common Lisp style, taken from a list.
+LIST specifies the list of values
+that the containing function should return."
+ list)
+
+(defsubst multiple-value-list (expression)
+ "Return a list of the multiple values produced by EXPRESSION.
+This handles multiple values in Common Lisp style, but it does not
+work right when EXPRESSION calls an ordinary Emacs Lisp function
+that returns just one value."
+ expression)
+
+(defsubst multiple-value-apply (function expression)
+ "Evaluate EXPRESSION to get multiple values and apply FUNCTION to them.
+This handles multiple values in Common Lisp style, but it does not work
+right when EXPRESSION calls an ordinary Emacs Lisp function that returns just
+one value."
+ (apply function expression))
+
+(defalias 'multiple-value-call 'apply
+ "Apply FUNCTION to ARGUMENTS, taking multiple values into account.
+This implementation only handles the case where there is only one argument.")
+
+(defsubst nth-value (n expression)
+ "Evaluate EXPRESSION to get multiple values and return the Nth one.
+This handles multiple values in Common Lisp style, but it does not work
+right when EXPRESSION calls an ordinary Emacs Lisp function that returns just
+one value."
+ (nth n expression))
;;; Macros.
(defvar *random-state* (vector 'cl-random-state-tag -1 30 (cl-random-time)))
-;;; We use `eval' in case VALBITS differs from compile-time to load-time.
-(defconst most-positive-fixnum (eval '(lsh -1 -1)))
-(defconst most-negative-fixnum (eval '(- -1 (lsh -1 -1))))
-
;;; The following are actually set by cl-float-limits.
(defconst most-positive-float nil)
(defconst most-negative-float nil)
(nreverse cl-res)))
(mapcar cl-func cl-x)))
+(defalias 'svref 'aref)
;;; List functions.
;; (while (consp (cdr x)) (pop x))
;; x))
-(defun butlast (x &optional n)
- "Returns a copy of LIST with the last N elements removed."
- (if (and n (<= n 0)) x
- (nbutlast (copy-sequence x) n)))
-
-(defun nbutlast (x &optional n)
- "Modifies LIST to remove the last N elements."
- (let ((m (length x)))
- (or n (setq n 1))
- (and (< n m)
- (progn
- (if (> n 0) (setcdr (nthcdr (- (1- m) n) x) nil))
- 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.
Thus, `(list* A B C D)' is equivalent to `(nconc (list A B C) D)', or to
"Non-nil means don't make CL functions autoload.")
;;; Autoload the other portions of the package.
+;; We want to replace the basic versions of dolist, dotimes, declare below.
+(fmakunbound 'dolist)
+(fmakunbound 'dotimes)
+(fmakunbound 'declare)
(mapcar (function
(lambda (set)
(let ((file (if cl-fake-autoloads "<none>" (car set))))
(defun cl-hack-byte-compiler ()
(if (and (not cl-hacked-flag) (fboundp 'byte-compile-file-form))
(progn
- (cl-compile-time-init) ; in cl-macs.el
- (setq cl-hacked-flag t))))
+ (setq cl-hacked-flag t) ; Do it first, to prevent recursion.
+ (cl-compile-time-init)))) ; In cl-macs.el.
;;; Try it now in case the compiler has already been loaded.
(cl-hack-byte-compiler)
(run-hooks 'cl-load-hook)
+;;; arch-tag: 5f07fa74-f153-4524-9303-21f5be125851
;;; cl.el ends here