;;;; -*- coding: utf-8; -*-
+ * new feature: SIMPLE-ARRAY-VECTOR provides access to the underlying
+ data vector of an multidimensional SIMPLE-ARRAY.
* optimization: faster generic arithmetic dispatch on x86 and x86-64.
* bug fix: lexical type declarations are now correctly reported by
SB-CLTL2. (reported by Larry D'Anna)
it still has quite a few. @xref{Contributed Modules}.
@menu
-* Garbage Collection::
-* Metaobject Protocol::
-* Support For Unix::
-* Customization Hooks for Users::
-* Tools To Help Developers::
-* Resolution of Name Conflicts::
-* Stale Extensions::
-* Efficiency Hacks::
+* Garbage Collection::
+* Metaobject Protocol::
+* Support For Unix::
+* Customization Hooks for Users::
+* Tools To Help Developers::
+* Resolution of Name Conflicts::
+* Miscellaneous Extensions::
+* Stale Extensions::
+* Efficiency Hacks::
@end menu
@node Garbage Collection
are:
@itemize
-
+
@item
@findex compute-effective-method
@findex sb-mop:compute-effective-method
precedence list of @code{generic-function} and
@code{standard-generic-function}, as required by section 1.4.4.5 of the
ANSI specification.
-
+
@item
@findex ensure-generic-function
@findex generic-function-declarations
@vindex *posix-argv*
The UNIX command line can be read from the variable
-@code{sb-ext:*posix-argv*}.
+@code{sb-ext:*posix-argv*}.
@node Querying the process environment
@subsection Querying the process environment
argument, which should be a member of the list returned by the condition
accessor @code{sb-ext:name-conflict-symbols}.
+@node Miscellaneous Extensions
+@comment node-name, next, previous, up
+@section Miscellaneous Extensions
+
+@include fun-sb-ext-simple-array-vector.texinfo
+
@node Stale Extensions
@comment node-name, next, previous, up
@section Stale Extensions
is @emph{not} appropriate for functions like @code{aref},
which can change their return values when the underlying data are
changed.
-@c <!-- FIXME: This declaration does not seem to be supported in the
+@c <!-- FIXME: This declaration does not seem to be supported in the
@c current compiler. -->
;; are assertions" default
"TRULY-THE"
+ ;; Misc. array and vector tools.
+ "SIMPLE-ARRAY-VECTOR"
+
;; This is something which must exist inside any Common
;; Lisp implementation, and which someone writing a
;; customized toplevel might well want. It seems perverse
(setf (%array-dimension array 0) dimensions))
(setf (%array-displaced-p array) displacedp)
array)
+
+;;; User visible extension
+(declaim (ftype (function (simple-array) (values (simple-array * (*)) &optional))
+ simple-array-vector))
+(defun simple-array-vector (array)
+ "Returns the one-dimensional SIMPLE-ARRAY corresponding to ARRAY.
+
+The ARRAY must be a SIMPLE-ARRAY. If ARRAY is multidimensional, returns the
+underlying one-dimensional SIMPLE-ARRAY which shares storage with ARRAY.
+Otherwise returns ARRAY.
+
+Currently in SBCL a multidimensional SIMPLE-ARRAY has an underlying
+one-dimensional SIMPLE-ARRAY, which holds the data in row major order. This
+function provides access to that vector.
+
+Important note: the underlying vector is an implementation detail. Even though
+this function exposes it, changes in the implementation may cause this
+function to be removed without further warning."
+ ;; KLUDGE: Without TRULY-THE the system is not smart enough to figure out that
+ ;; (1) SIMPLE-ARRAY without ARRAY-HEADER-P is a vector (2) the data vector of
+ ;; a SIMPLE-ARRAY is a vector.
+ (truly-the (simple-array * (*))
+ (if (array-header-p array)
+ (%array-data-vector array)
+ array)))
\f
;;;; used by SORT
(error (e)
(assert (eql 12 (type-error-datum e)))
(assert (equal '(integer 0 3) (type-error-expected-type e)))))))
+
+(with-test (:name simple-array-vector)
+ (let ((vec (vector 1 2 3)))
+ (assert (eq vec (sb-ext:simple-array-vector vec)))
+ (assert (equalp (vector 1 2 3 4)
+ (sb-ext:simple-array-vector
+ (make-array '(2 2) :initial-contents '((1 2) (3 4))))))
+ (assert (eq 'fixnum (array-element-type
+ (sb-ext:simple-array-vector (make-array '(3 4 5)
+ :element-type 'fixnum)))))))
;;; checkins which aren't released. (And occasionally for internal
;;; versions, especially for internal versions off the main CVS
;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.23.16"
+"1.0.23.17"