1 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; This software is derived from the CMU CL system, which was
5 ;;;; written at Carnegie Mellon University and released into the
6 ;;;; public domain. The software is in the public domain and is
7 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
8 ;;;; files for more information.
10 (in-package "SB!IMPL")
14 "If X is an atom, see whether it is present in *FEATURES*. Also
15 handle arbitrary combinations of atoms using NOT, AND, OR."
20 (error "too many subexpressions in feature expression: ~S" x)
21 (not (featurep (cadr x)))))
22 ((:and and) (every #'featurep (cdr x)))
23 ((:or or) (some #'featurep (cdr x)))
25 (error "unknown operator in feature expression: ~S." x)))
26 (not (null (memq x *features*)))))
28 ;;; KLUDGE: This is a wrapper around stale code for working with floating point
29 ;;; infinities. I believe that I will eventually eliminate floating point
30 ;;; infinities from the code, since they're a pain to cross-compile, since they
31 ;;; significantly increase the number of conditions which need to be tested in
32 ;;; numeric functions, and since the benefits which they provide (which are
33 ;;; admittedly significant) are unfortunately not portable. I haven't actually
34 ;;; done the dirty deed yet, though, and until then, I've wrapped various
35 ;;; infinity-returning forms in this macro. -- WHN 1999
36 (defmacro infinite (x)
37 (declare (ignorable x))
38 #!-sb-infinities '(error 'floating-point-overflow)
41 ;;; Given a list of keyword substitutions `(,OLD ,NEW), and a
42 ;;; keyword-argument-list-style list of alternating keywords and arbitrary
43 ;;; values, return a new keyword-argument-list-style list with all
44 ;;; substitutions applied to it.
46 ;;; Note: If efficiency mattered, we could do less consing. (But if efficiency
47 ;;; mattered, why would we be using keyword arguments at all, much less
48 ;;; renaming keyword arguments?)
50 ;;; KLUDGE: It would probably be good to get rid of this. -- WHN 19991201
51 (defun rename-keyword-args (rename-list keyword-args)
52 (declare (type list rename-list keyword-args))
53 ;; Walk through RENAME-LIST modifying RESULT as per each element in
55 (do ((result (copy-list keyword-args))) ; may be modified below
56 ((null rename-list) result)
57 (destructuring-bind (old new) (pop rename-list)
58 (declare (type keyword old new))
59 ;; Walk through RESULT renaming any OLD keyword argument to NEW.
60 (do ((in-result result (cddr in-result)))
62 (declare (type list in-result))
63 (when (eq (car in-result) old)
64 (setf (car in-result) new))))))
66 ;;; ANSI Common Lisp's READ-SEQUENCE function, unlike most of the
67 ;;; other ANSI input functions, is defined to communicate end of file
68 ;;; status with its return value, not by signalling. This is not the
69 ;;; behavior we usually want. This is a wrapper which give the
70 ;;; behavior we usually want, causing READ-SEQUENCE to communicate
71 ;;; end-of-file status by signalling.
72 (defun read-sequence-or-die (sequence stream &key start end)
73 ;; implementation using READ-SEQUENCE
74 #-no-ansi-read-sequence
75 (let ((read-end (read-sequence sequence
79 (unless (= read-end end)
80 (error 'end-of-file :stream stream))
82 ;; workaround for broken READ-SEQUENCE
83 #+no-ansi-read-sequence
85 (assert (<= start end))
86 (let ((etype (stream-element-type stream)))
87 (cond ((equal etype '(unsigned-byte 8))
88 (do ((i start (1+ i)))
91 (setf (aref sequence i)
93 (t (error "unsupported element type ~S" etype))))))