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 ;;; &KEY-argument-list-style list of alternating keywords and
43 ;;; arbitrary values, return a new &KEY-argument-list-style list with
44 ;;; all substitutions applied to it.
46 ;;; Note: If efficiency mattered, we could do less consing. (But if
47 ;;; efficiency mattered, why would we be using &KEY arguments at
48 ;;; all, much less renaming &KEY arguments?)
50 ;;; KLUDGE: It would probably be good to get rid of this. -- WHN 19991201
51 (defun rename-key-args (rename-list key-args)
52 (declare (type list rename-list key-args))
53 ;; Walk through RENAME-LIST modifying RESULT as per each element in
55 (do ((result (copy-list key-args))) ; may be modified below
56 ((null rename-list) result)
57 (destructuring-bind (old new) (pop rename-list)
58 ;; ANSI says &KEY arg names aren't necessarily KEYWORDs.
59 (declare (type symbol old new))
60 ;; Walk through RESULT renaming any OLD key argument to NEW.
61 (do ((in-result result (cddr in-result)))
63 (declare (type list in-result))
64 (when (eq (car in-result) old)
65 (setf (car in-result) new))))))
67 ;;; ANSI Common Lisp's READ-SEQUENCE function, unlike most of the
68 ;;; other ANSI input functions, is defined to communicate end of file
69 ;;; status with its return value, not by signalling. This is not the
70 ;;; behavior we usually want. This is a wrapper which give the
71 ;;; behavior we usually want, causing READ-SEQUENCE to communicate
72 ;;; end-of-file status by signalling.
73 (defun read-sequence-or-die (sequence stream &key start end)
74 ;; implementation using READ-SEQUENCE
75 #-no-ansi-read-sequence
76 (let ((read-end (read-sequence sequence
80 (unless (= read-end end)
81 (error 'end-of-file :stream stream))
83 ;; workaround for broken READ-SEQUENCE
84 #+no-ansi-read-sequence
87 (let ((etype (stream-element-type stream)))
88 (cond ((equal etype '(unsigned-byte 8))
89 (do ((i start (1+ i)))
92 (setf (aref sequence i)
94 (t (error "unsupported element type ~S" etype))))))