From 0912e50430cda83e41b8217f529fc7f0d99581cd Mon Sep 17 00:00:00 2001
From: "Liam M. Healy" <lnp@healy.washington.dc.us>
Date: Mon, 30 Nov 2009 16:17:31 -0500
Subject: [PATCH] Function #'number-class finds the CL class from the number
 type

Function #'number-class finds the CL class from the number type,
replacing the previous function #'number-class-from-type in
init/defmfun-array.lisp.  It is a bit more general.
---
 init/defmfun-array.lisp | 13 +++----------
 init/types.lisp         |  8 +++++++-
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/init/defmfun-array.lisp b/init/defmfun-array.lisp
index 9b2a6762..0edea019 100644
--- a/init/defmfun-array.lisp
+++ b/init/defmfun-array.lisp
@@ -1,6 +1,6 @@
 ;; Helpers for defining GSL functions on arrays
 ;; Liam Healy 2009-01-07 22:01:16EST defmfun-array.lisp
-;; Time-stamp: <2009-10-18 19:35:15EDT defmfun-array.lisp>
+;; Time-stamp: <2009-11-30 16:13:13EST defmfun-array.lisp>
 ;; $Id: $
 
 (in-package :gsl)
@@ -132,13 +132,6 @@
 			(string-downcase (symbol-name category)) :category
 			base-name))))))))))
 
-(defun number-class-from-type (type)
-  "Find a class name that contains this type."
-  ;; Not exhaustive; just trying to separate reals and complex.
-  (cond ((subtypep type 'complex) 'complex)
-	((subtypep type 'float) 'float)
-	(t (error "Can't pass type ~a." type))))
-
 (defun actual-class-arglist
     (arglist element-type c-arguments &optional replace-both)
   "Replace the prototype arglist with an actual arglist."
@@ -152,9 +145,9 @@
      (if (and replacing (listp arg))
 	 (list (first arg)
 	       (case (second arg)
-		 (:element-type (number-class-from-type element-type))
+		 (:element-type (number-class element-type))
 		 (:component-float-type
-		  (number-class-from-type (component-float-type element-type)))
+		  (number-class (component-float-type element-type)))
 		 (otherwise
 		  (data-class-name
 		   (if (and (eq (second arg) 'both) replace-both)
diff --git a/init/types.lisp b/init/types.lisp
index 5e498dcb..baef60e3 100644
--- a/init/types.lisp
+++ b/init/types.lisp
@@ -1,6 +1,6 @@
 ;; Number types used by GSL functions, and specification conversion
 ;; Liam Healy 2008-12-31 21:06:34EST types.lisp
-;; Time-stamp: <2009-11-14 10:54:53EST types.lisp>
+;; Time-stamp: <2009-11-30 16:13:18EST types.lisp>
 ;; $Id: $
 
 (in-package :gsl)
@@ -207,3 +207,9 @@
   "The CL type from the CFFI element type."
   (unless (eq cffi-type :pointer)
     (lookup-type cffi-type *cstd-cl-type-mapping*)))
+
+;;; For future use
+(defparameter *cl-numeric-classes* '(ratio integer rational float real complex number))
+(defun number-class (type)
+  "Find the class corresponding to the numeric type."
+  (find-if (lambda (class) (subtypep type class)) *cl-numeric-classes*))
-- 
GitLab